home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 569 / abzmon_s / abzmon.s
Text File  |  1991-10-19  |  102KB  |  3,760 lines

  1.  
  2. **** ABZMON, V1.1, by Alain Birtz, april 22, 1987
  3. **** ABZMON is public domain, it can be copied and distribued freely
  4.  
  5.     .text
  6.  
  7. bios    equ    13
  8. xbios    equ    14
  9. gemdos    equ    1
  10. tab    equ    9            * ascii tab code
  11. spc    equ    $20            * ascii space code
  12. comma    equ    44            * ascii comma code
  13. mnemo    equ    42
  14. ret_key    equ    $610000            * undo key
  15.  
  16.  
  17. *------------------------------------------------------------------------------*
  18.  
  19. * Release free memory not used by the monitor program
  20.  
  21.     move.l    a7,a0            * save stack pointer
  22.     move.l    #mon_stk,a7        * set monitor stack
  23.     move.l    4(a0),a0        * basepage address
  24.     move.l    $c(a0),d0        * prg length
  25.     add.l    $14(a0),d0        * data area length
  26.     add.l    $1c(a0),d0        * bss area length
  27.     add.l    #$100,d0        * reserve $100 long base page 
  28.     bsr    Mshrink            * release
  29.  
  30. *------------------------------------------------------------------------------*
  31.  
  32.     clr.l    -(sp)            * enter in supervisor mode
  33.     move.w    #$20,-(sp)
  34.     trap    #gemdos
  35.     addq.l    #6,sp
  36.     move.l    d0,sv_ssp
  37.  
  38.     bsr    excep_new        * initialise exeption vector
  39.  
  40.     lea    intro_s,a0        * intoduction string
  41.     bsr    prt_str
  42.  
  43.     move.l    #over,-(sp)        * stop walkback! (in monitor stack)
  44.     move.l    sp,mon_sp        * save monitor stack pointer
  45.     move.l    #over,prg_stk        * stop walkback! (in program stack)
  46.     move.l    #prg_stk-4,prg_sp    * set program stack pointer
  47.  
  48. sel_0    clr.b    wait_fg            * reset pause flag
  49.     lea    main_s,a0        * print main option
  50.     bsr    select
  51.     tst.b    d0            * default ?
  52.     bne    sel0_sv
  53.     moveq    #'D',d0            * defautl is disassembler
  54.     clr.b    indev            * no default on input, output device
  55.     clr.b    outdev
  56. sel0_sv    move.b    d0,op_main        * save main option
  57.     cmpi.b    #'D',d0            * disassembler ?
  58.     beq    sel_D
  59.     cmpi.b    #'T',d0            * trace ?
  60.     beq    sel_T
  61.     cmpi.b    #'H',d0            * hexa editor ?
  62.     beq    sel_H
  63.     cmpi.b    #'S',d0            * search ?
  64.     beq    sel_S
  65.     cmpi.b    #'F',d0            * free memory ?
  66.     beq    sel_F
  67.     cmpi.b    #'M',d0            * move data ?
  68.     beq    sel_M
  69.     cmpi.b    #'L',d0            * load program ?
  70.     beq    sel_L
  71.     cmpi.b    #'B',d0            * set break point ?
  72.     beq    sel_B
  73.     cmpi.b    #'G',d0            * (Go) run program ?
  74.     beq    sel_G
  75.     cmpi.b    #'R',d0            * change register value ?
  76.     beq    sel_R
  77.     cmpi.b    #'C',d0            * change CCR value ?
  78.     beq    sel_C
  79.     cmpi.b    #'I',d0            * display data and prg info ?
  80.     beq    sel_I
  81.     cmpi.b    #'E',d0            * Exit
  82.     beq    out
  83.     bra    sel_0
  84.  
  85. exit:                    * local exit
  86.     tst.w    ihandle            * input file openned ?
  87.     beq    exit2
  88.     move.w    ihandle,d0        * yes, close it
  89.     bsr    close
  90.     clr.w    ihandle
  91. exit2    cmpi.w    #3,ohandle        * output file openned ?
  92.     bls    exit3
  93.     lea    n_line,a0        * yes, write new line
  94.     move.l    #2,d0            * number of char to output
  95.     move.w    ohandle,d1        * output file handle
  96.     bsr    write            * write string
  97.     move.w    ohandle,d0        * and close the file
  98.     bsr    close
  99.     clr.w    ohandle
  100. exit3    move.l    mon_sp,sp        * restore monitor stack pointer
  101.     bra    sel_0
  102.  
  103. out:                    * return to parent process
  104.     bsr    excep_old        * restore exception vector
  105.  
  106.     move.l    sv_ssp,-(sp)        * exit supervisor mode
  107.     move.w    #$20,-(sp)
  108.     trap    #gemdos
  109.     addq.l    #6,sp
  110.  
  111.     lea    bye_s,a0
  112.     bsr    prt_str
  113.  
  114.     clr.w    -(sp)
  115.     trap    #gemdos            * Pterm0
  116.     rts
  117.  
  118. over:    andi    #$7fff,SR        * clear trace bit
  119.     lea    over_s,a0        * 'walkback over stack'
  120.     bsr    prt_str
  121.     bra    out
  122.  
  123. *------------------------------------------------------------------------------*
  124. *--------------------------- Load program routine -----------------------------*
  125. *------------------------------------------------------------------------------*
  126.  
  127. sel_L:    move.b    'P',indev
  128.     bsr    p_input            * load but not execute
  129.     bra    exit
  130.  
  131. *------------------------------------------------------------------------------*
  132. *---------------------------- Break point routine -----------------------------*
  133. *------------------------------------------------------------------------------*
  134.  
  135. sel_B:    move.l    $a0,svtrap8        * save old (trap #8) vector
  136.     move.l    #break_rout,$a0        * set new vector
  137. sel_B_    lea    break_s,a0        * break point address ?
  138.     bsr    prt_str
  139.     bsr    get_a5            * get value
  140.     tst.b    nil_val            * no default here
  141.     bne    sel_B_
  142.     move.l    a5,brkadr        * save address
  143.     move.w    (a5),brkcode        * save instr. code
  144.     move.w    #$4e48,(a5)        * change instr. code by trap #8 code
  145.     lea    brkno_s,a0        * how many time ?
  146.     bsr    prt_str
  147.     bsr    get_a5            * get value
  148.     tst.b    nil_val            * default value is 1 time
  149.     bne    sel_B_0
  150.     subq.l    #1,a5
  151. sel_B_0    move.l    a5,brkno        * save number
  152.     move.l    #single_step,$24    * set single step (trace) vector
  153.     bra    exit
  154.  
  155. *------------------------------------------------------------------------------*
  156.  
  157. break_rout:                * break (trap #8) routine
  158.  
  159.     move    SR,saveCCR        * save CCR
  160.     movem.l    d0-d7/a0-a7,regs    * save register
  161.     addq.l    #6,regs+60        * a7 before exeption
  162.     movea.l    brkadr,a5        * address of break point
  163.     move.w    brkcode,(a5)        * restore instr. code
  164.     tst.l    brkno            * last time to do the break point ?
  165.     bne    break_cont        * if no, do another break point
  166.     move.l    sp,prg_sp        * save program stack pointer
  167.     addq.l    #6,prg_sp
  168.     bra    break_exit
  169.  
  170. *------------------------------------------------------------------------------*
  171.  
  172. break_cont:                * do another break point
  173.  
  174.     subq.l    #1,brkno        * update counter
  175.     move.l    brkadr,2(sp)        * address to be single stepped
  176.     movem.l    regs,d0-d7/a0-a6    * restore register
  177.     ori    #$8000,(sp)        * set trace bit
  178.     rte                * execute brkadr instruction
  179.  
  180. *------------------------------------------------------------------------------*
  181.  
  182. break_exit:                * show register, CCR and exit
  183.  
  184.     lea    n_line,a0        * new line
  185.     bsr    prt_str
  186.     bsr    rev_on            * enter reverse video mode
  187.     bsr    disp_CCR        * fill s_CCR with a5 adr. and codeCCR
  188.     lea    s_CCR,a0
  189.     bsr    prt_str            * show address and status
  190.     bsr    rev_off            * exit reverse video mode
  191.     lea    str,a3
  192.     bsr    reg_disp        * register info
  193.     lea    str,a0
  194.     bsr    prt_str            * show register
  195.     move.l    brkadr,cur_adr        * become current adr.
  196.     move.l    svtrap8,$a0        * restore old (trap #8) vector
  197.     bra    exit
  198.  
  199. *------------------------------------------------------------------------------*
  200.  
  201. single_step:                * after execution of the brkadr instr.
  202.  
  203.     movem.l    a5,-(sp)        * save register
  204.     movea.l    brkadr,a5        * address of break point
  205.     move.w    #$4e48,(a5)        * change instr. code by trap #8 code
  206.     movem.l    (sp)+,a5        * restore register
  207.     andi    #$7fff,(sp)        * clear trace bit
  208.     rte                * continue the (ipname) program
  209.  
  210. *------------------------------------------------------------------------------*
  211. *---------------------------- Run program routine -----------------------------*
  212. *------------------------------------------------------------------------------*
  213.  
  214. sel_G:                    * NB: not breakpoint, exit monitor prg
  215.  
  216.     lea    adr_1st,a0        * start address
  217.     bsr    prt_str
  218.     bsr    get_a5            * get value
  219.     lea    n_line,a0        * new line
  220.     bsr    prt_str
  221.     tst.b    nil_val            * no value ?
  222.     bne    sel_G_0            * give default parameter
  223.     move.l    a5,cur_adr        * a5 address become current adr.
  224.  
  225. sel_G_0    move.l    prg_sp,sp        * change monitor stack for prg stack
  226.     move.l    cur_adr,-(sp)        * current adr. on stack
  227.  
  228.     move    saveCCR,CCR        * current prg. CCR
  229.     movem.l    regs,d0-d7/a0-a6    * current register
  230.     rts                * jump to cur_adr
  231.  
  232. *------------------------------------------------------------------------------*
  233. *------------------------- change regs value routine --------------------------*
  234. *------------------------------------------------------------------------------*
  235.  
  236. sel_R:    lea    str,a3            * output string
  237.     move.b    #27,(a3)+        * enter reverse video mode
  238.     move.b    #'p',(a3)+
  239.     bsr    reg_disp        * value in regs to ascii
  240.     lea    str,a0
  241.     bsr    prt_str            * display actual register
  242.     lea    R_s,a0            * initial position on screen
  243.     bsr    prt_str
  244.     moveq    #0,d3            * initial relative cursor position
  245.  
  246. * relative position are 0-7 for D0, 8-15 for D1, ... , 56-63 for D7
  247. * 64-71 for A0, ... , 120-127 for A7.
  248.  
  249. loop_R    bsr    ch_input        * read one char
  250.  
  251.     cmpi.l    #$500000,d0        * down key ?
  252.     beq    R_down            * go one line down
  253.     cmpi.l    #$480000,d0        * up key ?
  254.     beq    R_up            * go one line up
  255.     cmpi.l    #$4b0000,d0        * left key ?
  256.     beq    R_left            * go left one char
  257.     cmpi.l    #$4d0000,d0        * right key ?
  258.     beq    R_right            * go right one char
  259.     cmpi.l    #ret_key,d0        * exit key ?
  260.     beq    R_ex            * exit R_loop
  261.  
  262.     cmpi.b    #'V',d0            * down key ?
  263.     beq    R_down            * go one line down
  264.     cmpi.b    #'U',d0            * up key ?
  265.     beq    R_up            * go one line up
  266.     cmpi.b    #'L',d0            * left key ?
  267.     beq    R_left            * go left one char
  268.     cmpi.b    #'R',d0            * right key ?
  269.     beq    R_right            * go right one char
  270.     cmpi.b    #'Q',d0            * exit key ?
  271.     beq    R_ex            * exit R_loop
  272.  
  273.     cmpi.b    #'v',d0            * down key ?
  274.     beq    R_down            * go one line down
  275.     cmpi.b    #'u',d0            * up key ?
  276.     beq    R_up            * go one line up
  277.     cmpi.b    #'l',d0            * left key ?
  278.     beq    R_left            * go left one char
  279.     cmpi.b    #'r',d0            * right key ?
  280.     beq    R_right            * go right one char
  281.     cmpi.b    #'q',d0            * exit key ?
  282.     beq    R_ex            * exit R_loop
  283.  
  284.     bsr    asc_hx            * hexa char ?
  285.     bvc    R_hex            * yes, change the register value
  286.     bra    loop_R
  287.  
  288. R_ex    move.l    regs+60,prg_sp        * save new prg stack pointer
  289.     lea    R_ex_s,a0        * exit video mode
  290.     bsr    prt_str
  291.     bra    exit
  292.  
  293. *------------------------------------------------------------------------------*
  294.  
  295. R_down    cmpi.b    #64,d3            * second line ?
  296.     bcc    loop_R            * do nothing
  297.     addi.b    #64,d3            * update relative position
  298.     lea    down_s,a0        * move cursor down
  299.     bsr    prt_str
  300.     bra    loop_R
  301.  
  302. *------------------------------------------------------------------------------*
  303.  
  304. R_up    cmpi.b    #64,d3            * first line ?
  305.     bcs    loop_R            * do nothing
  306.     subi.b    #64,d3            * update relative position
  307.     lea    up_s,a0            * move cursor up
  308.     bsr    prt_str
  309.     bra    loop_R
  310.  
  311. *------------------------------------------------------------------------------*
  312.  
  313. R_left    tst.b    d3            * first positon of first line ?
  314.     beq    loop_R            * do nothing
  315.     cmpi.b    #64,d3            * first positon of second line ?
  316.     beq    loop_R            * do nothing
  317.     move.b    d3,d0            * now find relative position modulo 8
  318.     andi.b    #7,d0
  319.     bne    R_l_1            * if not at the 1st hexa digit, 1 left
  320.     lea    left_s,a0        * else move 2 left
  321.     bsr    prt_str
  322. R_l_1    lea    left_s,a0        * move cursor left
  323.     bsr    prt_str
  324.     subq.b    #1,d3            * update relative position
  325.     bra    loop_R
  326.  
  327. *------------------------------------------------------------------------------*
  328.  
  329. R_right    cmpi.b    #63,d3            * last positon of first line ?
  330.     beq    loop_R            * do nothing
  331.     cmpi.b    #127,d3            * last positon of second line ?
  332.     beq    loop_R            * do nothing
  333.     addq.b    #1,d3            * update relative position
  334.     move.b    d3,d0            * now find relative position modulo 8
  335.     andi.b    #7,d0
  336.     bne    R_r_1            * if not at the last hexa digit, only 1
  337.     lea    right_s,a0        * else move 2 right
  338.     bsr    prt_str
  339. R_r_1    lea    right_s,a0        * move cursor right
  340.     bsr    prt_str
  341.     bra    loop_R
  342.  
  343. *------------------------------------------------------------------------------*
  344.  
  345. R_hex    move.w    d3,d1            * find byte no of the current nibble
  346.     andi.w    #7,d1            *  no -> (7 & d3)/2
  347.     lsr.w    #1,d1
  348.  
  349.     move.w    d3,d2            * and register no
  350.     lsr.w    #3,d2
  351.     andi.w    #15,d2
  352.  
  353.     lsl.w    #2,d2            * offset in regs
  354.     add.w    d1,d2
  355.     lea    regs,a0
  356.     adda.w    d2,a0            * current register in regs
  357.     move.b    (a0),d1            * now split lo and hi part of the byte
  358.  
  359.     move.b    d0,d2
  360.     btst    #0,d3            * high or low nibble ?
  361.     beq    R_hi
  362.     andi.b    #$f0,d1            * clear lo part of regs
  363.     bra    R_add
  364. R_hi    lsl.b    #4,d2            * hex digit to high part
  365.     andi.b    #$f,d1            * clear high part of regs byte
  366.  
  367. R_add    add.b    d1,d2            * add lo and hi part
  368.     move.b    d2,(a0)            * back to regs
  369.  
  370.     addi.b    #'0',d0            * print hexa digit
  371.     cmpi.b    #'9',d0
  372.     bls    R_prt
  373.     addq.b    #7,d0
  374. R_prt    lea    R_chr_s,a0        * print char, cursor left
  375.     move.b    d0,(a0)
  376.     bsr    prt_str    
  377.     bra    R_right            * if possible one step 
  378.  
  379. *------------------------------------------------------------------------------*
  380. *---------------------- prg and data file info routine ------------------------*
  381. *------------------------------------------------------------------------------*
  382.  
  383. sel_I:    lea    data_s,a0        * DATA FILE:
  384.     bsr    prt_str
  385.     lea    idname,a0        * filename
  386.     bsr    prt_str
  387.     lea    from_s,a0        * display data file info
  388.     bsr    prt_str
  389.  
  390.     lea    prg_s,a0        * PRG FILE:
  391.     bsr    prt_str
  392.     lea    ipname,a0        * filename
  393.     bsr    prt_str
  394.     move.l    cur_adr,d2        * current adr.
  395.     lea    c_p_a_s+20,a0
  396.     bsr    d2_hx_l            * adr to hex
  397.     lea    c_p_a_s,a0        * print hex value
  398.     bsr    prt_str
  399.     lea    b_pg_s,a0        * display prg file info
  400.     bsr    prt_str
  401.     bra    exit
  402.  
  403. *------------------------------------------------------------------------------*
  404. *-------------------------- change CCR value routine --------------------------*
  405. *------------------------------------------------------------------------------*
  406.  
  407. sel_C:    lea    newCCRs,a0        * what new value
  408.     bsr    prt_str
  409.     bsr    get_a5            * get value
  410.     tst.b    nil_val            * no value, don't change any thing
  411.     bne    sel_C_x
  412.     move.w    a5,saveCCR
  413. sel_C_x    bra    exit
  414.  
  415. *------------------------------------------------------------------------------*
  416. *---------------------------- Free memory routine -----------------------------*
  417. *------------------------------------------------------------------------------*
  418.  
  419. sel_F:    moveq    #-1,d0            * get free space
  420.     bsr    Malloc
  421.  
  422.     move.l    d0,d2            * show free memory
  423.     lea    free_s+15,a0
  424.     bsr    d2_hx_l
  425.     lea    free_s,a0
  426.     bsr    prt_str
  427.  
  428.     bsr    get_a5            * get needed memory
  429.     tst.b    nil_val            * no value ?
  430.     bne    exit
  431.     movea.l    a5,a4            * save value
  432.  
  433.     move.l    a5,d0            * reserve space
  434.     beq    exit            * if zero, return
  435.     bsr    Malloc
  436.  
  437.     movea.l    d0,a5            * start address
  438.     adda.l    a5,a4            * end address
  439.     bsr    Data_info        * show both address
  440.     bra    exit
  441.  
  442. *------------------------------------------------------------------------------*
  443. *----------------------------- Move data routine ------------------------------*
  444. *------------------------------------------------------------------------------*
  445.  
  446. sel_M:    lea    s_move,a0
  447.     bsr    select            * choice...
  448.     tst.b    d0            * default ?
  449.     beq    f_mem            * default is no 1
  450.     cmpi.b    #'0',d0            * Exit
  451.     beq    exit
  452.     cmpi.b    #'1',d0            * file to memory
  453.     beq    f_mem
  454.     cmpi.b    #'2',d0            * memory to file
  455.     beq    mem_f
  456.     cmpi.b    #'3',d0            * memory to memory
  457.     beq    mem_m
  458.     bra    sel_M
  459.  
  460. *------------------------------------------------------------------------------*
  461.  
  462. f_mem:    lea    idname,a0        * input data filename
  463.     bsr    getname            * pathname or filename
  464.     bsr    getsize            * size of the file
  465. f_mem_    lea    adr_1st,a0        * start address
  466.     bsr    prt_str
  467.     bsr    get_a5            * get value
  468.     tst.b    nil_val            * no default here
  469.     bne    f_mem_
  470.     lea    idname,a0        * input data filename
  471.     bsr    open            * open file
  472.     bsr    read            * read file
  473.     bsr    Data_info        * display start and end address
  474.     bra    exit
  475.  
  476. *------------------------------------------------------------------------------*
  477.  
  478. mem_f:    bsr    m_input            * start and end address
  479.     bsr    create            * create the destination file
  480.     move.l    save1st,a0        * beggining of write buffer
  481.     move.l    saveend,d0
  482.     sub.l    a0,d0            * buffer length
  483.     addq.l    #1,d0
  484.     move.w    ohandle,d1        * output file handle
  485.     bsr    write            * do the file and exit
  486.     bra    exit
  487.  
  488. *------------------------------------------------------------------------------*
  489.  
  490. mem_m:    lea    src_s,a0        * SOURCE
  491.     bsr    prt_str
  492.     bsr    m_input            * start and end address of source
  493.     lea    n_line,a0        * new line
  494.     bsr    prt_str
  495.     movea.l    a5,a3            * save start address
  496.     lea    dest_s,a0        * DESTINATION
  497.     bsr    prt_str
  498. mem_m_    lea    adr_1st,a0        * start address of destination
  499.     bsr    prt_str
  500.     bsr    get_a5            * get value
  501.     tst.b    nil_val            * no default here
  502.     bne    mem_m_
  503.     lea    n_line,a0        * new line
  504.     bsr    prt_str
  505.  
  506. mem_m_l    move.b    (a3)+,(a5)+        * move data loop
  507.     cmpa.l    a3,a4
  508.     bge    mem_m_l
  509.  
  510.     bra    exit
  511.  
  512. *------------------------------------------------------------------------------*
  513. *--------------------------- Search main routine ------------------------------*
  514. *------------------------------------------------------------------------------*
  515.  
  516. sel_S:    bsr    outputf            * get output
  517.     bsr    inputf            * get input device
  518.     clr.b    srch_fg            * initialise found flag
  519. sel_S_    lea    srch_s,a0        * Ascii string or Byte string
  520.     bsr    select
  521.     tst.b    d0            * default ?
  522.     beq    srch_a            * default is ascii
  523.     cmpi.b    #'A',d0            * Ascii
  524.     beq    srch_a
  525.     cmpi.b    #'B',d0            * Byte
  526.     beq    srch_b
  527.     cmpi.b    #'E',d0            * Exit
  528.     beq    exit
  529.     bra    sel_S_
  530.  
  531. *------------------------------------------------------------------------------*
  532.  
  533. srch_a    lea    ascii_s,a0        * get search string
  534.     bsr    prt_str
  535.     lea    srchstr,a0        * read search string    
  536.     moveq    #20,d0            * 20 char maximum
  537.     bsr    read_str
  538.     lea    srchstr,a0        * here, do the wildcard string
  539.     lea    wildstr,a3
  540. a_wild    tst.b    (a0)            * end of string ?
  541.     beq    a_ready            * yes, ready to search
  542.     cmpi.b    #'?',(a0)+        * wildcard symbol ?
  543.     seq    (a3)+            * if yes set, else clr
  544.     bra    a_wild
  545.  
  546. a_ready move.l    a0,d0
  547.     subi.l    #srchstr,d0        * string length
  548.     lea    srchstr,a0        * ready to search
  549.     cmpi.b    #2,d0
  550.     bcs    exit            * need    minimum 2 char
  551.     movea.l    save1st,a1
  552.     movea.l    saveend,a2
  553.     lea    wildstr,a3
  554.  
  555. a_find    bsr    nx_find
  556.     move.l    srchreg,d3        * byte number
  557.     andi.w    #$ff,d3            * only byte part
  558.     subq.w    #1,d3            * counter
  559.     lea    str+33,a0        * output string
  560. ascopy    move.b    (a1)+,d0        * ascii representation
  561.     cmpi.b    #' ',d0
  562.     bcs    a_dot            * only char >= 32 or <127
  563.     cmpi.b  #127,d0
  564.     bhi    a_dot
  565.     bra    a_ok
  566. a_dot    moveq    #'.',d0
  567. a_ok    move.b    d0,(a0)+
  568.     dbra    d3,ascopy
  569.     clr.b    (a0)            * null terminate string
  570.  
  571.     cmpi.b    #'S',outdev        * Screen ?
  572.     bne    a_not_S
  573.     bsr    S_srch
  574.     bra    a_cont
  575. a_not_S    bsr    F_srch            * file: printer or disk 
  576.  
  577. a_cont    movem.l    srchreg,d0/a0-a4    * restore register
  578.     addq.l    #1,a1
  579.     bra    a_find            * loop
  580.  
  581. *------------------------------------------------------------------------------*
  582.  
  583. srch_b    lea    byte_s,a0        * get search string
  584.     bsr    prt_str
  585.     lea    str,a0            * read search string    
  586.     moveq    #60,d0            * 60 char maximum
  587.     bsr    read_str
  588.     lea    srchstr,a0        * here, do the wildcard string
  589.     lea    str,a1
  590.     lea    wildstr,a3
  591.  
  592. b_wild    move.b    (a1)+,d0        * end of string ?
  593.     beq    b_ready            * yes, ready to search
  594.     cmpi.b    #' ',d0
  595.     beq    b_wild            * skip white space
  596.     cmpi.b    #'?',d0            * wildcard symbol ?
  597.     bne    b_hexa            * no, keep hexa value
  598.     st    (a3)+            * if yes set
  599.     addq.l    #1,a0            * next char in srchstr
  600.     bra    b_wild
  601. b_hexa    bsr    asc_hx            * hi nibble value
  602.     bvs    srch_b            * no hexa value, retry
  603.     lsl.b    #4,d0            * multiply by 16
  604.     move.b    d0,(a0)            * and store
  605.     move.b    (a1)+,d0        * next char
  606.     bsr    asc_hx            * lo nibble value
  607.     bvs    srch_b            * no hexa value, retry
  608.     add.b    d0,(a0)+        * add tp previous value
  609.     sf    (a3)+            * not wildcard byte
  610.     bra    b_wild
  611.  
  612. b_ready move.l    a0,d0
  613.     subi.l    #srchstr,d0        * string length
  614.     cmpi.b    #2,d0
  615.     bcs    exit            * need    minimum 2 char
  616.     lea    srchstr,a0        * ready to search
  617.     movea.l    save1st,a1
  618.     movea.l    saveend,a2
  619.     lea    wildstr,a3
  620.  
  621. b_find    bsr    nx_find
  622.     move.l    srchreg,d3        * byte number
  623.     andi.w    #$ff,d3            * only byte part
  624.     subq.w    #1,d3            * counter
  625.     lea    str+33,a0        * output string
  626. b_byte    move.b    (a1)+,d2        * byte value
  627.     bsr    d2_hx_b            * byte representation
  628.     addq.l    #2,a0
  629.     move.b    #' ',(a0)+
  630.     dbra    d3,b_byte
  631.     clr.b    -1(a0)
  632.  
  633.     cmpi.b    #'S',outdev        * Screen ?
  634.     bne    b_not_S
  635.     bsr    S_srch
  636.     bra    b_cont
  637. b_not_S    bsr    F_srch            * file: printer or disk 
  638.  
  639. b_cont    movem.l    srchreg,d0/a0-a4    * restore register
  640.     addq.l    #1,a1
  641.     bra    b_find            * loop
  642.  
  643. *------------------------------------------------------------------------------*
  644.  
  645. nx_find    bsr    find
  646.     cmpa.l    a2,a1            * greather than end address ?
  647.     bgt    srch_ex
  648.     st    srch_fg            * 'I have found something' flag
  649.     movem.l    d0/a0-a4,srchreg    * save register
  650.     lea    str,a3            * output string
  651.     move.l    a1,d2            * actual address in memory
  652.     cmpi.b    #'D',indev        * input device: Data file ?
  653.     bne    nx_f_mp            * or Memory or Prg file
  654.     sub.l    save1st,d2        * file offset
  655.     lea    fileoff,a0        * found at file offset $
  656.     bra    nx_f_2
  657. nx_f_mp    lea    found_s,a0        * found at memory adr. $
  658. nx_f_2    bsr    copy_s
  659.     lea    str+24,a0
  660.     bsr    d2_hx_l            * found address
  661.     move.b    #' ',str+32
  662.     rts
  663.  
  664.  
  665. srch_ex    tst.b    srch_fg            * find something ?
  666.     bne    find_ex
  667.     lea    notfind,a0        * sorry...
  668.     bsr    prt_str
  669.     bsr    ch_input
  670.     bra    exit
  671. find_ex    lea    n_line,a0        * new line
  672. find_2    bsr    prt_str
  673.     bra    exit
  674.  
  675. *------------------------------------------------------------------------------*
  676.  
  677. find                * search for a string in memory
  678.                 * a0 is the address the string, d0 is length
  679.                 * a1 the start address for the search and
  680.                 * a2 the end adddress
  681.                 * a3 is the address of the wildcard string
  682.                 * '0' mean no widcard, '1' mean wildcard
  683.                 * a3 and a1 are associated byte to byte
  684.                 * and wildcard string must always begin by '0'
  685.                 * To return
  686.                 * a1 is the address of the first occurence or
  687.                 * a2 + 1 if the string is not found
  688.                 * other register not affected
  689.     movem.l    d0-d3/a0/a2,-(sp)
  690.     subq.b    #1,d0
  691.     move.b    (a0),d3        * first char of the string 
  692. nx_mem    clr.w    d1        * char counter
  693. chr_1st    cmpa.l    a2,a1
  694.     bgt    fd_exit
  695.     cmp.b    (a1)+,d3
  696.     bne    chr_1st
  697. nx_chr    addq.b    #1,d1        * if first char match, try next
  698.     tst.b    0(a3,d1.w)    * wildcard?
  699.     bne    no_test        * if yes, don't do the next test
  700.     move.b    0(a0,d1.w),d2
  701.     cmp.b    -1(a1,d1.w),d2
  702.     bne    nx_mem        * if second char not match
  703. no_test    cmp.b    d0,d1
  704.     bne    nx_chr        * try until incomplete string
  705.     subq.l    #1,a1
  706. fd_exit    movem.l    (sp)+,d0-d3/a0/a2
  707.     rts
  708.  
  709. *------------------------------------------------------------------------------*
  710.  
  711. S_srch    lea    str,a0
  712.     bsr    prt_str            * show
  713.     bsr    ch_input        * and wait
  714.     cmpi.l    #ret_key,d0        * loop until  exit key
  715.     beq    exit
  716.     cmpi.b    #'Q',d0
  717.     beq    exit
  718.     cmpi.b    #'q',d0
  719.     beq    exit
  720.     rts
  721.  
  722. *------------------------------------------------------------------------------*
  723.  
  724. F_srch    lea    str,a0            * write buffer
  725.     moveq    #-1,d0            * count string length
  726. F_count    addq.l    #1,d0
  727.     tst.b    (a0)+
  728.     bne    F_count            * d0 is the number of char to output 
  729.     move.w    ohandle,d1        * output file handle
  730.     lea    str,a0            * output string
  731.     bra    write            * write string
  732.  
  733. *------------------------------------------------------------------------------*
  734. *------------------------- Hexa editor main routine ---------------------------*
  735. *------------------------------------------------------------------------------*
  736.  
  737. sel_H:    bsr    outputf            * get output
  738.     bsr    inputf            * get input
  739.     cmpi.b    #'S',outdev        * Screen ?
  740.     beq    S_ed
  741.     bsr    ed_line            * printer or file
  742.     bra    exit
  743.  
  744. S_ed    clr.b    altd_fg            * clear altered flag
  745.     bsr    ed_init            * initialise with white space
  746.     suba.l    #16,a5
  747.     bsr    down            * go to user
  748.     bsr    altered            * file is modified ? save ?
  749.     bra    exit
  750.  
  751. *------------------------------------------------------------------------------*
  752.  
  753. ed_line    bsr    ed_init            * initialise with white space
  754.     lea    str+79,a0
  755.     move.b    #13,(a0)        * plus carriage return
  756.     move.b    #10,(a0)+        * plus line feed
  757.  
  758. ed_lp    cmpa.l    a5,a4            * while start address < end address
  759.     bcs    ed_ret            * (return)
  760.     bsr    adr_hx            * address to hexadecimal ascii
  761.     bsr    infbyte            * byte to hexa value and char ascii
  762.  
  763.     moveq    #15,d1            * counter. change non printable by dot
  764.     lea    str+62,a0        * beggining of the ascii representation
  765. dotloop    move.b    (a0),d0            * the char to print
  766.     cmpi.b    #32,d0            * test for printable char
  767.     bcs    do_dot            
  768.     cmpi.b    #127,d0
  769.     bcs    dotnext
  770. do_dot    move.b    #'.',(a0)        * replace by a dot
  771. dotnext    addq.w    #1,a0
  772.     dbra    d1,dotloop
  773.  
  774.     lea    str,a0            * write buffer
  775.     moveq    #80,d0            * number of char to output
  776.     move.w    ohandle,d1        * output file handle
  777.     bsr    write            * write string
  778.     adda.l    #16,a5            * ready for next line
  779.     bra    ed_lp
  780.  
  781. *------------------------------------------------------------------------------*
  782.  
  783. ed_init    moveq    #79,d0            * initialise the ascii str
  784.     lea    str,a0
  785. init_s    move.b    #' ',(a0)+
  786.     dbra    d0,init_s
  787. ed_ret    rts
  788.  
  789. *------------------------------------------------------------------------------*
  790.  
  791. infbyte:                * byte hexa value and ascii char
  792.  
  793.     lea    str+13,a0        * hexa bytes area
  794.     lea    str+62,a1        * ascii representation area
  795.     moveq    #15,d1            * counter
  796.     movem.l    a5,-(sp)        * save a5
  797.  
  798. do_inf    move.b    (a5)+,d0        * pick byte
  799.     bne    cdiff0            * non null char ?
  800.     move.b    #46,(a1)+        * if non, use '.' instead
  801.     bra    infcont
  802. cdiff0    move.b    d0,(a1)+        * char representation
  803. infcont    move.b    d0,-(sp)        * save d0
  804.     lsr.b    #4,d0            * high nibble
  805.     bsr    nibble            * conversion
  806.     move.b    d0,(a0)+        * store the value
  807.     move.b    (sp)+,d0        * restore d0
  808.     andi.b    #$F,d0            * low nibble
  809.     bsr    nibble            * conversion
  810.     move.b    d0,(a0)+        * store the value
  811.     addq.l    #1,a0            * pass over one space
  812.     dbra    d1,do_inf        * loop until d1 > -1
  813.     movem.l    (sp)+,a5        * restore a5
  814.     rts
  815.  
  816. nibble    addi.b    #48,d0            * ascii digit
  817.     cmpi.b    #57,d0            * > 9 ?
  818.     bgt    nodigit            * no, it is a letter
  819.     rts
  820.  
  821. nodigit    addq.b    #7,d0            * char is A,B,...
  822.     rts
  823.     
  824. *------------------------------------------------------------------------------*
  825.  
  826. scrline:                * special printing for the screen
  827.  
  828.     movem.l    d4/a4,-(sp)        * save d4, a4
  829.     move.b    #13,d0            * go to start of line
  830.     bsr    prt_chr
  831.     lea    str,a4            * beggining of the ascii line
  832.     moveq    #0,d4            * counter
  833.  
  834. scrloop    move.b    (a4)+,d0        * the char to print
  835.     cmpi.b    #1,d4            * test start address area
  836.     bne    scrl_1
  837.     bsr    rev_on
  838. scrl_1    cmpi.b    #11,d4            * test end address area
  839.     bne    scrl_2
  840.     bsr    rev_off
  841. scrl_2    cmpi.b    #62,d4            * test start ascii area
  842.     bne    scrl_3
  843.     bsr    rev_on
  844. scrl_3    cmpi.b    #78,d4            * test end ascii area
  845.     beq    scrl_ex
  846.  
  847.     moveq    #5,d1            * device is console without control
  848.     bsr    conout            * print
  849.     addq.b    #1,d4
  850.     bra    scrloop            * loop until d4 > 77
  851. scrl_ex    bsr    rev_off
  852.     move.b    #13,d0            * go to start of line
  853.     bsr    prt_chr
  854.     movem.l    (sp)+,d4/a4        * restore saved register
  855.     rts
  856.  
  857. *------------------------------------------------------------------------------*
  858.  
  859. showln:                    * display the line to the screen
  860.  
  861.     bsr    adr_hx            * address to hexadecimal ascii
  862.     bsr    infbyte            * byte to hexa value and char ascii
  863.     bra    scrline            * display
  864.  
  865. *------------------------------------------------------------------------------*
  866.  
  867. input:                    * main action routine
  868.  
  869.     bsr    ch_input        * read user input
  870.  
  871. inptst:    cmpi.l    #ret_key,d0        * exit key ?
  872.     beq    inp_ex            * yes, return
  873.     cmpi.b    #'Q',d0
  874.     beq    inp_ex
  875.     cmpi.b    #'q',d0
  876.     beq    inp_ex
  877.  
  878.     cmpi.l    #$500000,d0        * down key ?
  879.     beq    down            * display one line down
  880.     cmpi.b    #'V',d0
  881.     beq    down
  882.     cmpi.b    #'v',d0
  883.     beq    down
  884.  
  885.     cmpi.l    #$480000,d0        * up key ?
  886.     beq    up            * display one line up
  887.     cmpi.b    #'U',d0
  888.     beq    up
  889.     cmpi.b    #'u',d0
  890.     beq    up
  891.  
  892.     cmpi.l    #$4d0000,d0        * right key
  893.     beq    right            * move right
  894.     cmpi.b    #'R',d0
  895.     beq    right
  896.     cmpi.b    #'r',d0
  897.     beq    right
  898.  
  899.     cmpi.l    #$4b0000,d0        * left key
  900.     beq    left            * move left
  901.     cmpi.b    #'L',d0
  902.     beq    left
  903.     cmpi.b    #'l',d0
  904.     beq    left
  905.  
  906.     cmpi.l    #$4d0036,d0        * shift right key
  907.     beq    sh_right        * move in ascii area
  908.  
  909.     bra    input            * infinite loop
  910.  
  911. inp_ex    rts
  912.  
  913. *------------------------------------------------------------------------------*
  914.  
  915. down:                    * response to down key
  916.  
  917.     move.w    #-1,cur_fg        * no horizontal move flag
  918.     lea    n_line,a0        * new line
  919.     bsr    prt_str
  920.     adda.l    #16,a5            * update address
  921.     bsr    showln            * display line
  922.     bra    input            * ready for next input
  923.  
  924. *------------------------------------------------------------------------------*
  925.  
  926. up:                    * response to up key
  927.  
  928.     move.w    #-1,cur_fg        * no horizontal move flag
  929.     lea    up_ln,a0        * move cursor up and to the beginning
  930.     bsr    prt_str
  931.     suba.l    #16,a5            * update address
  932.     bsr    showln            * display line
  933.     bra    input            * ready for next input
  934.  
  935. *------------------------------------------------------------------------------*
  936.  
  937. left:                    * response to left key
  938.  
  939.     tst.w    cur_fg            * byte zero ?
  940.     beq    l_beg            * yes, go to beginning of line
  941.     cmpi.w    #-1,cur_fg        * beginning of line ?
  942.     beq    end_prv            * go to last byte of previous line
  943.     moveq    #3,d1            * else move left 3 char
  944.     subq.w    #1,cur_fg        * and update flag
  945.     bsr    l_move
  946.     bra    mem_wr            * ready to modify the byte
  947.  
  948. end_prv    move.w    #15,cur_fg        * update flag
  949.     suba.l    #16,a5            * update address
  950.     lea    up_ln,a0        * one line up
  951.     bsr    prt_str
  952.     moveq    #58,d1            * move to the previous byte
  953.     bsr    r_move
  954.     bra    mem_wr
  955.  
  956. l_beg    moveq    #13,d0            * carriage return
  957.     bsr    prt_chr
  958.     move.w    #-1,cur_fg        * update flag
  959.     bra    input            * ready for next input
  960.  
  961. *------------------------------------------------------------------------------*
  962.  
  963. right:                    * response to right key
  964.  
  965.     cmpi.w    #-1,cur_fg        * flag = -1 ?
  966.     beq    byte0            * yes, move to the first line byte
  967.     cmpi.w    #15,cur_fg        * flag >= 15 ? (16 bytes only)
  968.     bge    down            * yes, one line down
  969.     moveq    #3,d1
  970. r_cont    bsr    r_move            * else move right 3 char
  971.     addq.w    #1,cur_fg        * and update flag
  972.     bra    mem_wr            * ready to modify the byte
  973.  
  974. byte0    moveq    #13,d1            * move to the first line byte
  975.     bra    r_cont
  976.  
  977. *------------------------------------------------------------------------------*
  978.  
  979. mem_wr:                    * write a byte in the line
  980.  
  981.     bsr    cur_s            * save cursor pos
  982.     clr.b    wr_fg            * clear the flag
  983.     clr.w    d2
  984.     bsr    rd_hx            * read 1st nibble
  985.     tst.b    wr_fg            * flag clear ?
  986.     beq    other
  987.     move.b    d1,d2            * store result
  988.     lsl.w    #4,d2            * mult by 16
  989.     bsr    rd_hx            * take second nibble
  990.     add.b    d1,d2            * add to previous value
  991.     move.w    cur_fg,d0
  992.     move.b    d2,0(a5,d0.w)        * write the new value
  993.     bsr    showln            * redisplay line
  994.     bsr    cur_r            * restore cursor pos
  995.     bra    mem_wr            * re_write or next input
  996.  
  997. other    bsr    cur_r            * restore cursor pos
  998.     bra    inptst            * test for other kind of input
  999.  
  1000. *------------------------------------------------------------------------------*
  1001.  
  1002. rd_hx:                    * test hexa char value
  1003.                     * don't return until valid char is read
  1004.                     * value hold in d1, char in d0
  1005.  
  1006.     st    altd_fg            * set altered flag
  1007.     bsr    ch_input        * read one char
  1008.     movem.l    d0,-(sp)        * save d0
  1009.     cmpi.l    #$400000,d0        * not ascii ?
  1010.     bcc    v_err            * do other test
  1011.     bsr    asc_hx            * convert to hexa value
  1012.     bvs    v_err            * error ? go termination
  1013.     move.b    d0,d1            * the return value
  1014.     movem.l    (sp)+,d0        * restore d0
  1015.     st    wr_fg            * set flag
  1016.     cmpi.b    #97,d0            * if lower case, do upper case
  1017.     bcs    do_prt
  1018.     subi.b    #32,d0
  1019. do_prt    bra    prt_chr            * print it, and return
  1020.  
  1021. v_err    movem.l    (sp)+,d0        * restore d0
  1022.     tst.b    wr_fg            * non valid
  1023.     bne    rd_hx            * if second char, re-read
  1024.     rts                * else return
  1025.  
  1026. *------------------------------------------------------------------------------*
  1027.  
  1028. cur_s:                    * save cursor position
  1029.  
  1030.     lea    c_s,a0
  1031.     bra    prt_str
  1032.     
  1033. *------------------------------------------------------------------------------*
  1034.  
  1035. cur_r:                    * save cursor position
  1036.  
  1037.     lea    c_r,a0
  1038.     bra    prt_str
  1039.     
  1040. *------------------------------------------------------------------------------*
  1041.  
  1042. r_move:                    * move d1 step to right
  1043.  
  1044.     lea    mv_str,a0
  1045.     subq.w    #1,d1            * counter
  1046. r_fill    move.b    #27,(a0)+        * fill the move string
  1047.     move.b    #67,(a0)+
  1048.     dbra    d1,r_fill
  1049.     clr.b    (a0)
  1050.     lea    mv_str,a0
  1051.     bra    prt_str            * move
  1052.  
  1053. *------------------------------------------------------------------------------*
  1054.  
  1055. l_move:                    * move d1 step to left
  1056.  
  1057.     lea    mv_str,a0
  1058.     subq.w    #1,d1            * counter
  1059. l_fill    move.b    #27,(a0)+        * fill the move string
  1060.     move.b    #68,(a0)+
  1061.     dbra    d1,l_fill
  1062.     clr.b    (a0)
  1063.     lea    mv_str,a0
  1064.     bra    prt_str            * move
  1065.  
  1066. *------------------------------------------------------------------------------*
  1067.  
  1068. sh_right:                * response to shift left key
  1069.  
  1070.     moveq    #13,d0            * carriage return
  1071.     bsr    prt_chr
  1072. a_area    moveq    #62,d1            * move to ascii area
  1073.     bsr    r_move
  1074.     move.w    #0,cur_fg        * 1st char position
  1075.  
  1076. rd_asc    bsr    ch_input        * read one char
  1077.     cmpi.l    #$4b0034,d0        * shift left arrow ?
  1078.     beq    sh_l_ex            * yes, exit shift left routine
  1079.     cmpi.l    #$500000,d0        * down key ?
  1080.     beq    a_down            * go one line down
  1081.     cmpi.l    #$480000,d0        * up key ?
  1082.     beq    a_up            * go one line up
  1083.     cmpi.l    #$4b0000,d0        * left key
  1084.     beq    a_left            * go left one char
  1085.     cmpi.l    #$4d0000,d0        * right key
  1086.     beq    a_right            * go right one char
  1087.  
  1088. wr_asc    st    altd_fg            * set altered flag
  1089.     move.w    cur_fg,d1
  1090.     move.b    d0,0(a5,d1.w)        * write the new value
  1091.     bsr    cur_s            * save cursor pos
  1092.     bsr    showln            * redisplay line
  1093.     bsr    cur_r            * restore cursor pos
  1094.  
  1095. a_right    moveq    #1,d1
  1096.     bsr    r_move            * move one char right
  1097.     addq.w    #1,cur_fg        * update cursor flag
  1098.     cmpi.w    #15,cur_fg        * flag <= 15 ?
  1099.     ble    rd_asc            * yes, next char
  1100.  
  1101. a_down    move.w    #0,cur_fg        * set cursor flag
  1102.     lea    n_line,a0        * new line
  1103.     bsr    prt_str
  1104.     adda.l    #16,a5            * update address
  1105.     bsr    showln            * display line
  1106.     bra    a_area            * ready for next char
  1107.  
  1108. a_left    moveq    #1,d1
  1109.     bsr    l_move            * move one char left
  1110.     subq.w    #1,cur_fg        * update cursor flag
  1111.     tst.w    cur_fg            * non negative ?
  1112.     bpl    rd_asc            * yes, next char
  1113.  
  1114. a_up    move.w    #0,cur_fg        * set cursor flag
  1115.     lea    up_ln,a0        * move cursor up and to the beginning
  1116.     bsr    prt_str
  1117.     suba.l    #16,a5            * update address
  1118.     bsr    showln            * display line
  1119.     bra    a_area            * ready for next char
  1120.  
  1121. sh_l_ex    moveq    #13,d0            * carriage return
  1122.     bsr    prt_chr
  1123.     move.w    #-1,cur_fg        * reset cursor flag
  1124.     bra    input            * ready for next input
  1125.  
  1126. *------------------------------------------------------------------------------*
  1127. *------------------------ Disassembler main routine ---------------------------*
  1128. *------------------------------------------------------------------------------*
  1129.  
  1130. sel_D:    bsr    outputf            * get output
  1131.     bsr    inputf            * get input
  1132.     bclr    #0,save1st+3        * odd address ?
  1133.     move.l    save1st,a5
  1134.     cmpi.b    #'S',outdev        * Screen ?
  1135.     beq    S_dis
  1136.     bra    F_dis            * file: printer or disk 
  1137.  
  1138. *------------------------------------------------------------------------------*
  1139.  
  1140. S_dis    bsr    disasm
  1141.     lea    str,a0            * output
  1142.     bsr    prt_str
  1143.     bsr    ch_input
  1144.     cmpi.l    #ret_key,d0        * loop until exit key
  1145.     beq    exit
  1146.     cmpi.b    #'Q',d0
  1147.     beq    exit
  1148.     cmpi.b    #'q',d0
  1149.     beq    exit
  1150.  
  1151.     bra    S_dis
  1152.  
  1153. *------------------------------------------------------------------------------*
  1154.  
  1155. F_dis    move.l    saveend,d0        * while start address < end address
  1156.     cmp.l    a5,d0
  1157.     bcs    exit            * (return)
  1158.     bsr    disasm
  1159.     lea    str,a0            * write buffer
  1160.     move.l    d3,d0            * number of char to output
  1161.     move.w    ohandle,d1        * output file handle
  1162.     bsr    write            * write string
  1163.     bra    F_dis            * ready for next line
  1164.  
  1165. *------------------------------------------------------------------------------*
  1166.  
  1167. disasm:
  1168.  
  1169.     movea.l    a5,a4            * a5 is the address of the opcode
  1170.     addq.l    #2,a4            * a4 the next (extention) word
  1171.  
  1172.     lea    str+mnemo,a3        * start of mnemotechnics code
  1173.     bsr    drv            * disassemble
  1174.  
  1175.     lea    str,a0            * print address
  1176.     move.b    #13,(a0)+
  1177.     move.b    #10,(a0)+
  1178.     move.b    #' ',(a0)+
  1179.     move.l    a5,d2
  1180.     bsr    d2_hx_l
  1181.     addi.l    #8,a0
  1182.     move.b    #' ',(a0)+
  1183.     move.b    #' ',(a0)+
  1184.     move.b    #' ',(a0)+
  1185.  
  1186. opcode    move.w    (a5)+,d2        * print opcode
  1187.     bsr    d2_hx_w
  1188.     addq.l    #4,a0
  1189.     move.b    #' ',(a0)+
  1190.     cmpa.l    a5,a4
  1191.     bhi    opcode
  1192.  
  1193.     lea    str,a1            * space up to column before mnemo.
  1194.     adda.l    #mnemo-1,a1
  1195. col_mne    move.b    #' ',(a0)+
  1196.     cmpa.l    a0,a1
  1197.     bcc    col_mne
  1198.  
  1199.     lea    str,a0            * upon return d3 is the string length
  1200.     move.l    a3,d3
  1201.     sub.l     a0,d3
  1202.     rts
  1203.  
  1204. *------------------------------------------------------------------------------*
  1205.  
  1206. term    clr.b    (a3)            * terminate mnemo. string
  1207.     
  1208.     rts
  1209.  
  1210. *------------------------------------------------------------------------------*
  1211. *------------------------- Trace main routine ---------------------------------*
  1212. *------------------------------------------------------------------------------*
  1213.  
  1214. sel_T:    bsr    outputf            * get output
  1215.     bsr    inputf            * get input
  1216.     tst.b    nil_val            * if memory input and default value
  1217.     bne    sel_T_0            * take default parameter
  1218.     bclr    #0,save1st+3        * odd address ?
  1219.     move.l    save1st,cur_adr        * become current address
  1220. sel_T_0    bra    trace            * initialise trace
  1221.  
  1222. *------------------------------------------------------------------------------*
  1223.  
  1224. trace:                    * initialise trace
  1225.  
  1226.     clr.b    sp_up            * stack up flag
  1227.     clr.b    sp_dn            * stack down flag
  1228.     clr.b    sp_eq            * stack equal flag
  1229.     move.l    #trace_rout,$24        * trace vector
  1230.     move.l    prg_sp,sp        * change monitor stack for prg stack
  1231.     move.l    cur_adr,-(sp)        * start address to trace
  1232.     move    SR,d0
  1233.     move.w    saveCCR,d1        * restore previously saved CCR
  1234.     andi.w    #$ff,d1
  1235.     or.w    d1,d0
  1236.     ori.w    #$8000,d0        * set trace bit
  1237.     move.w    d0,-(sp)
  1238.     movem.l    regs,d0-d7/a0-a6    * restore previously saved register
  1239.     rte                * do trace
  1240.  
  1241. *------------------------------------------------------------------------------*
  1242.  
  1243. trace_rout:                * trace routine
  1244.  
  1245.     move    SR,saveCCR        * save CCR
  1246.     movem.l    d0-d7/a0-a7,regs    * save register
  1247.     addq.l    #6,regs+60        * a7 before exeption
  1248.  
  1249.     tst.b    sp_up            * if shift left key has been hitted
  1250.     bne    do_up            * wait sp go up
  1251.     tst.b    sp_dn            * if shift right key has been hitted
  1252.     bne    do_dn            * wait sp go down
  1253.     tst.b    sp_eq            * if shift equal key has been hitted
  1254.     bne    do_eq            * wait sp go up or down
  1255.  
  1256. trcshow    move.l    cur_adr,a5        * PC value
  1257.     lea    str,a3
  1258.  
  1259.     cmpi.b    #'S',outdev        * Screen ?
  1260.     beq    S_trace
  1261.  
  1262.     bsr    dis_trc            * (here file=output) dissassemble
  1263.     bsr    reg_disp        * register info
  1264.     lea    str,a0            * write buffer
  1265.     move.l    d3,d0            * number of char to output
  1266.     move.w    ohandle,d1        * output file handle
  1267.     bsr    write            * write string
  1268.     lea    str,a0            * and also print to screen
  1269.     bsr    prt_str            * but no reverse video mode...
  1270.  
  1271. trcloop    btst    #7,(sp)            * test the Trace bit of SR
  1272.     bne    trc1            * if set, continue
  1273.     lea    excep_s,a0        * else it is an other exception
  1274.     bsr    prt_str            * give info
  1275.     move.l    8(sp),cur_adr        * for the next instruction
  1276.     bra    trc2
  1277. trc1    move.l    2(sp),cur_adr        * for the next instruction
  1278. trc2    movem.l    regs,d0-d7/a0-a6    * restore register
  1279.     rte                * ready for next instruction
  1280.  
  1281. S_trace    lea    r_on_s,a0        * (here screen=output)
  1282.     bsr    copy_s            * enter reverse video mode
  1283.     bsr    dis_trc            * dissassemble
  1284.     lea    r_off_s,a0
  1285.     bsr    copy_s            * exit reverse video mode
  1286.     bsr    reg_disp        * register info
  1287.     lea    str,a0
  1288.     bsr    prt_str
  1289.  
  1290.     bsr    ch_input        * pause
  1291.     cmpi.l    #$4d0036,d0        * shift right arrow ?
  1292.     beq    trc_rgt            * wait sp go down (like in BSR)
  1293.     cmpi.b    #'R',d0
  1294.     beq    trc_rgt
  1295.     cmpi.b    #'r',d0
  1296.     beq    trc_rgt
  1297.     cmpi.l    #$4b0034,d0        * shift left arrow ?
  1298.     beq    trc_lft            * wait sp go up (like in RTS) 
  1299.     cmpi.b    #'L',d0
  1300.     beq    trc_lft
  1301.     cmpi.b    #'l',d0
  1302.     beq    trc_lft
  1303.     cmpi.b    #$2b,d0            * equal key ?
  1304.     beq    trc_equ            * wait sp go up or down
  1305.     cmpi.l    #ret_key,d0        * exit key ?
  1306.     beq    trc_ex
  1307.     cmpi.b    #'Q',d0
  1308.     beq    trc_ex
  1309.     cmpi.b    #'q',d0
  1310.     beq    trc_ex
  1311.     bra    trcloop            * no, loop
  1312.  
  1313. trc_ex    btst    #7,(sp)            * test the Trace bit of SR
  1314.     bne    trc11            * if set, continue
  1315.     move.l    8(sp),cur_adr        * for the next instruction
  1316.     bra    trc22
  1317. trc11    move.l    2(sp),cur_adr        * for the next instruction
  1318. trc22    move.l    sp,prg_sp        * save program stack pointer
  1319.     addq.l    #6,prg_sp
  1320.     andi    #$7fff,SR        * clear trace bit
  1321.     bra    exit            * return
  1322.  
  1323. *-----------------------------------------------------------------------------*
  1324.  
  1325. * routine answer to the shift up or down and equal key
  1326.  
  1327. trc_rgt    st    sp_dn            * set down stack flag
  1328.     bra    trcnt
  1329.  
  1330. trc_lft    st    sp_up            * set up stack flag
  1331.     bra    trcnt
  1332.  
  1333. trc_equ    st    sp_eq            * set equal stack flag
  1334. trcnt    clr.l    trcount            * initialise counter
  1335.     move.l    sp,sp_1st        * stack pointer reference
  1336.     lea    work_s,a0        * working...
  1337.     bsr    prt_str
  1338.     bra    trcloop            * trace next instruction
  1339.  
  1340. * note: add 6 for the current instruction sp. since the comparison (below)
  1341. * will be do after the trace exception, this relative value is correct
  1342.  
  1343. do_up    cmpa.l    sp_1st,sp        * new sp is higher than old ?
  1344.     bgt    dotrcnt            * display intruction count, continue
  1345.     addq.l    #1,trcount        * update instruction counter
  1346.     bra    trcloop            * do_up again (skip display)
  1347.  
  1348. do_dn    cmpa.l    sp_1st,sp        * new sp is lower than old ?
  1349.     blt    dotrcnt            * display intruction count, continue
  1350.     addq.l    #1,trcount        * update instruction counter
  1351.     bra    trcloop            * do_dn again (skip display)
  1352.  
  1353. do_eq    cmpa.l    sp_1st,sp        * new sp is no equal to the old ?
  1354.     bne    dotrcnt            * display intruction count, continue
  1355.     addq.l    #1,trcount        * update instruction counter
  1356.     bra    trcloop            * do_eq again (skip display)
  1357.  
  1358. dotrcnt    move.l    trcount,d2        * number of instruction traced
  1359.     lea    trcnt_s+10,a0        * message
  1360.     bsr    d2_hx_l            * number to hex
  1361.     lea    trcnt_s,a0        * print hex value
  1362.     bsr    prt_str
  1363.     clr.b    sp_up            * stack up flag
  1364.     clr.b    sp_dn            * stack down flag
  1365.     clr.b    sp_eq            * stack equal flag
  1366.     bra    trcshow            * display last traced instruction
  1367.  
  1368. *------------------------------------------------------------------------------*
  1369.  
  1370. dis_trc:                * show the disassembled trace instr.
  1371.  
  1372.     movea.l    a5,a4            * a5 is the address of the opcode
  1373.     addq.l    #2,a4            * a4 the next (extention) word
  1374.     bsr    disp_CCR        * fill s_CCR with a5 adr. and codeCCR
  1375.     lea    s_CCR,a0
  1376.     bsr    copy_s            * copy to str
  1377.     bsr    drv            * disassemble
  1378.     move.b    #' ',(a3)+
  1379.     clr.b    (a3)
  1380.     move.l    a3,d3
  1381.     sub.l    #str,d3            * byte number
  1382.     rts
  1383.  
  1384. *------------------------------------------------------------------------------*
  1385.  
  1386. disp_CCR:                * fill s_CCR with a5 adr. and codeCCR
  1387.  
  1388.     lea    s_CCR+3,a0
  1389.     move.l    a5,d2
  1390.     bsr    d2_hx_l            * show address
  1391.  
  1392.     moveq    #4,d2
  1393.     lea    s_CCR+22,a0        * status string address
  1394.     lea    codeCCR,a1        * status code
  1395. CCRtest    btst    d2,saveCCR+1        * test bit d2 of CCR
  1396.     bne    CCRnot0
  1397.     move.b    #'-',(a0)+        * bit = 0 -> "-"
  1398.     addq.l    #1,a1            * next code
  1399.     bra    CCRloop
  1400. CCRnot0    move.b    (a1)+,(a0)+        * one of X,N,Z,V,C code
  1401. CCRloop    dbra    d2,CCRtest
  1402.     rts
  1403.  
  1404. *------------------------------------------------------------------------------*
  1405.  
  1406. reg_disp:                * display register info at a3
  1407.  
  1408.     lea    regs,a2            * register value
  1409.  
  1410.     move.b    #13,(a3)+        * carriage return
  1411.     move.b    #10,(a3)+        * line feed
  1412.     move.b    #'D',(a3)+
  1413.     bsr    reg_hx            * display data register
  1414.  
  1415.     move.b    #13,(a3)+        * carriage return
  1416.     move.b    #10,(a3)+        * line feed
  1417.     move.b    #'A',(a3)+
  1418.     bsr    reg_hx            * display address register
  1419.  
  1420.     clr.b    (a3)
  1421.     move.l    a3,d3
  1422.     sub.l    #str,d3            * byte number
  1423.     rts
  1424.  
  1425. reg_hx    moveq    #7,d3            * loop counter
  1426. reg_lp    move.b    #' ',(a3)+
  1427.     move.l    (a2)+,d2        * register value
  1428.     movea.l    a3,a0
  1429.     bsr    d2_hx_l            * to ascii
  1430.     adda.l    #8,a3            * update pointer    
  1431.     dbra    d3,reg_lp        * and loop until d3 = -1
  1432.     rts
  1433.  
  1434. *------------------------------------------------------------------------------*
  1435. *----------------------- input source, output destination----------------------*
  1436. *------------------------------------------------------------------------------*
  1437.  
  1438. outputf:                * get output device
  1439.  
  1440.     clr.w    ohandle
  1441.     lea    out_s,a0
  1442.     bsr    select            * screen, exit, printer or file ?
  1443.     tst.b    d0            * default ?
  1444.     bne    outsave
  1445.     moveq    #'S',d0            * default is screen
  1446. outsave    move.b    d0,outdev
  1447.     cmpi.b    #'E',d0            * Exit
  1448.     beq    exit
  1449.     cmpi.b    #'S',d0            * Screen
  1450.     beq    outp_ex            * just return
  1451.     cmpi.b    #'F',d0            * File
  1452.     beq    create            * create file
  1453.     cmpi.b    #'P',d0
  1454.     bne    outputf
  1455.     move.w    #3,ohandle        * handle for printer
  1456. outp_ex    rts
  1457.  
  1458. *------------------------------------------------------------------------------*
  1459.  
  1460. inputf:                    * get input device
  1461.  
  1462.     clr.w    ihandle
  1463.     lea    in_s,a0
  1464.     bsr    select            * exit, memory, program or data file ?
  1465.     tst.b    d0            * default ?
  1466.     bne    insave
  1467.     moveq    #'M',d0            * default is memory
  1468. insave    move.b    d0,indev
  1469.     cmpi.b    #'E',d0            * Exit
  1470.     beq    exit
  1471.     cmpi.b    #'D',indev
  1472.     beq    d_input            * input is a data file
  1473.     cmpi.b    #'P',indev
  1474.     beq    p_input            * input is a program file
  1475.     cmpi.b    #'M',indev
  1476.     beq    m_input            * input is memory
  1477.     bra    inputf
  1478.  
  1479. *------------------------------------------------------------------------------*
  1480.  
  1481. m_input:                * get memory address
  1482.  
  1483.     lea    adr_1st,a0        * start address
  1484.     bsr    prt_str
  1485.     cmpi.b    #'S',op_main        * in Search, need both address
  1486.     beq    m_inp2
  1487.     cmpi.b    #'M',op_main        * in Move (data), need both address
  1488.     beq    m_inp2
  1489.     cmpi.b    #'T',op_main        * in Trace, need only one address
  1490.     beq    m_inp1
  1491.     cmpi.b    #'S',outdev        * for other option
  1492.     bne    m_inp2
  1493. m_inp1    bsr    get_a5            * if output is screen no need end adr.
  1494.     tst.b    nil_val            * default ?
  1495.     beq    m_inp_
  1496.     move.l    cur_adr,a5        * default is current adr.
  1497. m_inp_    move.l    a5,save1st        * save start address
  1498.     rts
  1499.  
  1500. m_inp2    lea    c_s,a0            * save cursor position
  1501.     bsr    prt_str
  1502.     bsr    get_a5            * end address
  1503.     tst.b    nil_val            * default ?
  1504.     beq    m_2_
  1505.     move.l    cur_adr,a5        * default is current adr.
  1506. m_2_    move.l    a5,save1st        * save start address
  1507.     lea    c_r,a0            * restore cursor position
  1508.     bsr    prt_str
  1509.     lea    adr_end,a0
  1510.     bsr    prt_str
  1511.     bsr    get_a5
  1512.     tst.b    nil_val            * default ?
  1513.     beq    m_2__
  1514.     move.l    save1st,a5        * default is start adr. + $ffff
  1515.     adda.l    #$ffff,a5
  1516. m_2__    move.l    a5,saveend        * save end address
  1517.     movea.l    a5,a4            * end address
  1518.     movea.l    save1st,a5        * restore start address
  1519.     rts
  1520.  
  1521. *------------------------------------------------------------------------------*
  1522.  
  1523. d_input:                * get input data file
  1524.  
  1525.     lea    idname,a0        * input data filename
  1526.     bsr    getname            * pathname or filename
  1527.     bsr    getsize            * size of the file
  1528.     move.l    d4,d0
  1529.     bsr    Malloc            * reserve memory space
  1530.     move.l    d0,a5            * start address
  1531.     move.l    a5,save1st
  1532.     move.l    d0,a4
  1533.     adda.l    d4,a4            * end address
  1534.     move.l    a4,saveend
  1535.     lea    idname,a0        * input data filename
  1536.     bsr    open            * open file
  1537.     bsr    read            * read file
  1538.     bra    Data_info        * display start and end address
  1539.  
  1540. *------------------------------------------------------------------------------*
  1541.  
  1542. getsize:                * d4 hold the size of the file 'idname'
  1543.  
  1544.     move.w    #$2f,-(sp)        * function number: get dta
  1545.     trap    #gemdos            * get disk transfert address
  1546.     addq.l    #2,sp            * update stack
  1547.     move.l    d0,dta
  1548.  
  1549.  
  1550.     move.w    #-1,-(sp)        * file affribute: any kind
  1551.     move.l    #idname,-(sp)        * address of pathname or filename
  1552.     move.w    #$4e,-(sp)        * function number: sfirst
  1553.     trap    #gemdos            * file exist ?
  1554.     addq.l    #8,sp            * update stack
  1555.     tst.w    d0
  1556.     bne    io_error        * file not found
  1557.  
  1558.     move.l    dta,a0            * here file exist: found file size
  1559.     move.l    26(a0),d4        * size
  1560.     rts
  1561.  
  1562. *------------------------------------------------------------------------------*
  1563.  
  1564. Malloc:                    * byte space in d0, return adr in d0
  1565.  
  1566.     move.l    d0,-(sp)        * reserve space
  1567.     move.w    #$48,-(sp)        * function number: Malloc
  1568.     trap    #gemdos
  1569.     addq.l    #6,sp            * update stack
  1570.     tst.l    d0            * <= 0 is error
  1571.     ble    no_mem
  1572.     rts
  1573.  
  1574. no_mem    moveq    #-39,d0            * insufficient memory
  1575.     bra    io_error
  1576.  
  1577. *------------------------------------------------------------------------------*
  1578.  
  1579. Mshrink:                * shrink block at a0 to d0 size
  1580.  
  1581.     move.l    d0,-(sp)        * length of memory to free
  1582.     move.l    a0,-(sp)        * start address of this memory
  1583.     move    d0,-(sp)        * junk word
  1584.     move    #$4a,-(sp)        * function number (Mshrink)
  1585.     trap    #gemdos
  1586.     add.l    #12,sp            * update stack
  1587.     rts
  1588.  
  1589. *------------------------------------------------------------------------------*
  1590.  
  1591. Data_info:                * display start and end address
  1592.  
  1593.     move.l    a5,d2            * start address
  1594.     lea    from_s+11,a0
  1595.     bsr    d2_hx_l            * value to ascii
  1596.     move.l    a4,d2            * end address
  1597.     lea    from_s+24,a0
  1598.     bsr    d2_hx_l            * value to ascii
  1599.     lea    from_s,a0
  1600.     bra    prt_str            * display
  1601.  
  1602. *------------------------------------------------------------------------------*
  1603.  
  1604. p_input:                * get input program file
  1605.  
  1606.     tst.l    base_pg            * first prg loaded ?
  1607.     beq    p_inp2            * if zero, it is first
  1608.     movea.l    base_pg,a0        * else release memory of previous prg
  1609.     moveq    #0,d0
  1610.     bsr    Mshrink
  1611. p_inp2    lea    ipname,a0        * input prg filename
  1612.     bsr    getname            * pathname or filename
  1613.     bsr    argline            * split filename and command tail
  1614.     bsr    loadprg            * load, but not execute
  1615.     bra    Prg_info        * display base page info
  1616.  
  1617. *------------------------------------------------------------------------------*
  1618.  
  1619. Prg_info:                * display base page info
  1620.  
  1621.     move.l    d0,base_pg        * base page
  1622.     move.l    d0,a1
  1623.  
  1624.     lea    b_pg_s+11,a0        * show text start
  1625.     move.l    $8(a1),d2        * start address
  1626.     movea.l    d2,a5
  1627.     move.l    d2,cur_adr        * become current adr.
  1628.     move.l    d2,save1st        * save it
  1629.     bsr    d2_hx_l
  1630.     lea    b_pg_s+21,a0        * show text end
  1631.     move.l    $c(a1),d2        * text length
  1632.     add.l    $8(a1),d2
  1633.     subq.l    #1,d2            * end address
  1634.     movea.l    d2,a4
  1635.     move.l    d2,saveend        * save it
  1636.     bsr    d2_hx_l
  1637.  
  1638.     lea    b_pg_s+38,a0        * show data start
  1639.     move.l    $10(a1),d2        * start address
  1640.     bsr    d2_hx_l
  1641.     lea    b_pg_s+48,a0        * show data end
  1642.     move.l    $14(a1),d2        * data length
  1643.     add.l    $10(a1),d2
  1644.     subq.l    #1,d2            * end address
  1645.     bsr    d2_hx_l
  1646.  
  1647.     lea    b_pg_s+64,a0        * show bbs start
  1648.     move.l    $18(a1),d2        * start address
  1649.     bsr    d2_hx_l
  1650.     lea    b_pg_s+74,a0        * show bbs end
  1651.     move.l    $1c(a1),d2        * text length
  1652.     add.l    $18(a1),d2
  1653.     subq.l    #1,d2            * end address
  1654.     bsr    d2_hx_l
  1655.  
  1656.     lea    b_pg_s,a0        * print it
  1657.     bra    prt_str
  1658.  
  1659. *------------------------------------------------------------------------------*
  1660.  
  1661. altered:                * altered file need save ?
  1662.  
  1663.     tst.b    altd_fg            * file altered ?
  1664.     beq    altd_ex            * no, return
  1665.     cmpi.b    #'S',outdev        * output is screen ?
  1666.     bne    altd_ex            * no, return
  1667.     cmpi.b    #'D',indev        * input is data file ?
  1668.     bne    altd_ex            * no, return
  1669.     lea    altd_s,a0        * yes, display message
  1670.     bsr    select            * answer
  1671.     cmpi.b    #'Y',d0
  1672.     bne    altd_ex            * not Y, return
  1673.  
  1674.     lea    idname,a0        * input data filename
  1675.     bsr    open            * pathname already in idname
  1676.     move.w    ihandle,d1        * file handle
  1677.     move.l    save1st,a0        * beggining of write buffer
  1678.     move.l    saveend,d0
  1679.     sub.l    a0,d0            * buffer length
  1680.     bsr    write            * save it
  1681.     bra    ch_input
  1682.  
  1683. altd_ex    rts
  1684.  
  1685. *------------------------------------------------------------------------------*
  1686.  
  1687. select:                    * user option
  1688.  
  1689.     bsr    prt_str            * print option
  1690.     moveq    #2,d0            * read 2 char max.
  1691.     lea    str,a0
  1692.     bsr    read_str
  1693.     tst.b    d0            * default ?
  1694.     beq    sel_ex
  1695.     move.b    (a0),d0            * option
  1696.     cmpi.b    #'a',d0
  1697.     bcs    sel_ex
  1698.     subi.b    #32,d0            * to upper case
  1699. sel_ex    rts
  1700.  
  1701. *------------------------------------------------------------------------------*
  1702.  
  1703. getname:                * get pathname (and command tail)
  1704.  
  1705.     move.l    a0,-(sp)        * save filename address
  1706.     lea    name_s,a0        * message
  1707.     bsr    prt_str
  1708.     move.l    (sp)+,a0        * restore filename address
  1709.     moveq    #70,d0            * 64 char max
  1710.     bra    read_str
  1711.  
  1712. *------------------------------------------------------------------------------*
  1713.  
  1714. argline:                * split filename and command tail
  1715.  
  1716.     lea    ipname,a1
  1717.     bsr    get_arg            * get filename
  1718.     cmpa.l    #0,a3            * other argument ?
  1719.     bne    arg1            * there is argument!
  1720.     clr.b    1(a2)            * end of ipname
  1721.     clr.b    tail            * number of argument (zero)
  1722.     rts
  1723.  
  1724. arg1    clr.b    1(a2)            * end of ipname
  1725.     movea.l    a3,a1            * start of the next argument
  1726.     lea    tail+1,a3        * tail adr. + 1
  1727.     movea.l    a1,a0            * copy next arument to tail
  1728.     bsr    copy_s
  1729.     clr.b    (a3)            * null terminate
  1730.  
  1731.     moveq    #1,d1            * number of argument counter
  1732. argplus    bsr    get_arg            * find argument
  1733.     cmpa.l    #0,a3            * other argument ?
  1734.     beq    arg_ret            * while not end of string
  1735.     movea.l    a3,a1            * start of the next argument
  1736.     addq.b    #1,d1            * number of argument
  1737.     bra    argplus
  1738.  
  1739. arg_ret    move.b    d1,tail            * number of argument in 1st byte
  1740.     rts
  1741.  
  1742. *------------------------------------------------------------------------------*
  1743.  
  1744. get_arg:
  1745.  
  1746. * a1 is the beginning of the argument, a2 will be the end of argument
  1747. * a3 will be the beginning of the next argument, or 0 if there are not
  1748. * other argument. skip white space and tab 
  1749.  
  1750.     movea.l    a1,a0
  1751. non_w    move.b    (a0)+,d0        * current char
  1752.     beq    no_arg            * end of string, no more argument
  1753.     cmpi.b    #' ',d0            * white space ?
  1754.     beq    skip_w
  1755.     cmpi.b    #tab,d0            * tab ?
  1756.     bne    non_w            * ckeck another char
  1757.  
  1758. skip_w    lea    -2(a0),a2        * end of argument
  1759. skip_l    move.b    (a0)+,d0        * current char
  1760.     cmpi.b    #' ',d0            * white space ?
  1761.     beq    skip_l
  1762.     cmpi.b    #tab,d0            * tab ?
  1763.     beq    skip_l
  1764.     lea    -1(a0),a3        * beginning of the next argument
  1765.     rts
  1766.  
  1767.  
  1768. no_arg    lea    -1(a0),a2        * end of argument
  1769.     movea.l    #0,a3            * no other argument
  1770.     rts
  1771.  
  1772. *------------------------------------------------------------------------------*
  1773.  
  1774. get_a5:                    * get deci or hexa value to a5
  1775.  
  1776.     clr.b    nil_val            * no value flag
  1777.     moveq    #15,d0            * 12 char max
  1778.     lea    str,a0            * read address
  1779.     bsr    read_str
  1780.     tst.b    d0            * number of char read
  1781.     beq    no_val            * if 0, give info
  1782.     cmpi.b    #'#',(a0)        * 1st char is # ?
  1783.     beq    get_dec            * yes, decimal value
  1784.     bsr    a_to_hx            * else hexa value
  1785.     bra    mv_adr
  1786. get_dec    addq.l    #1,a0            * skip char #
  1787.     bsr    a_to_dec
  1788. mv_adr    movea.l    d1,a5            * address
  1789.     rts
  1790.  
  1791. no_val    st    nil_val            * set flag
  1792.     clr.l    a5            * why not ?
  1793.     rts
  1794.  
  1795. *------------------------------------------------------------------------------*
  1796. *--------------------------- I/O routine --------------------------------------*
  1797. *------------------------------------------------------------------------------*
  1798.  
  1799. close:                    * close file
  1800.  
  1801.     move.w    d0,-(sp)        * file handle
  1802.     move.w    #$3e,-(sp)        * function number: Fclose
  1803.     trap    #gemdos
  1804.     addq.l    #4,sp            * update stack
  1805.     tst.w    d0
  1806.     bmi    io_error        * d0 < 0 is error
  1807.     rts
  1808.  
  1809. *------------------------------------------------------------------------------*
  1810.  
  1811. open:                    * open a file on disk
  1812.  
  1813.     move.w    #2,-(sp)        * can be read or write
  1814.  
  1815.     move.l    a0,-(sp)        * address of pathname or filename
  1816.     move.w    #$3d,-(sp)        * function number
  1817.     trap    #gemdos
  1818.     addq.l    #8,sp            * update stack
  1819.     move.w    d0,ihandle        * input file handle
  1820.     tst.w    d0
  1821.     bmi    io_error        * d0 < 0 is error
  1822.     rts
  1823.  
  1824. *------------------------------------------------------------------------------*
  1825.  
  1826. write:                    * write on file (disk or printer)
  1827.  
  1828.     move.l    a0,-(sp)        * text buffer
  1829.     move.l    d0,-(sp)        * length of text
  1830.     move.w    d1,-(sp)        * file handle
  1831.     move.w    #$40,-(sp)        * function number: Fwrite
  1832.     trap    #gemdos
  1833.     adda.l    #12,sp            * update stack
  1834.     tst.l    d0
  1835.     bmi    io_error        * d0 < 0 is error
  1836.  
  1837.     move.w    #$b,-(sp)        * function number: Cconis
  1838.     trap    #gemdos            * (check keyboard status)
  1839.     adda.l    #2,sp            * update stack
  1840.     tst.w    d0            * press one key ?
  1841.     beq    write_x            * 0 -> no
  1842. wr_ch    bsr    ch_input        * -1 -> yes, then read it
  1843.     cmpi.l    #ret_key,d0        * exit key ?
  1844.     beq    exit            * yes,  close file and exit
  1845.     cmpi.b    #'Q',d0
  1846.     beq    exit
  1847.     cmpi.b    #'q',d0
  1848.     beq    exit
  1849.     cmpi.b    #spc,d0            * space bar ?
  1850.     beq    wr_wait            * yes, pause
  1851. write_x    rts                * if not: ignore the key, continue
  1852.  
  1853. wr_wait    not.b    wait_fg            * 1 -> first time: wait
  1854.     bne    wr_p            * 0 -> second time: continue
  1855.     lea    cont_s,a0
  1856.     bsr    prt_str
  1857.     rts
  1858.  
  1859. wr_p    lea    pause_s,a0
  1860.     bsr    prt_str
  1861.     bra    wr_ch            * wair for an other hit (space bar)
  1862.  
  1863. *------------------------------------------------------------------------------*
  1864.  
  1865. read:                    * read file
  1866.  
  1867.     move.l    a5,-(sp)        * text buffer
  1868.     move.l    d4,-(sp)        * length of text
  1869.     move.w    ihandle,-(sp)        * file handle
  1870.     move.w    #$3f,-(sp)        * function number: Fread
  1871.     trap    #gemdos
  1872.     adda.l    #12,sp            * update stack
  1873.     tst.l    d0
  1874.     bmi    io_error        * d0 < 0 is error
  1875.     rts
  1876.  
  1877. *------------------------------------------------------------------------------*
  1878.  
  1879. create:                    * create (and open) a file on disk
  1880.  
  1881.     lea    odname,a0        * output data filename
  1882.     bsr    getname
  1883.      move.w    #0,-(sp)        * R/W status
  1884.     pea    odname            * address of pathname or filename
  1885.     move.w    #$3c,-(sp)        * function number: Fcreate
  1886.     trap    #gemdos
  1887.     addq.l    #8,sp            * update stack
  1888.     move.w    d0,ohandle        * output file handle
  1889.     tst.w    d0
  1890.     bmi    io_error        * d0 < 0 is error
  1891.     rts
  1892.  
  1893. *------------------------------------------------------------------------------*
  1894.  
  1895. loadprg:                * load program and  show base page info
  1896.  
  1897.     clr.l    -(sp)            * no environment string
  1898.     pea    tail            * command tail address
  1899.     pea    ipname            * pathname
  1900.     move.w    #3,-(sp)        * load, but not execute
  1901.     move.w    #$4b,-(sp)        * function number: Pexec
  1902.     trap    #gemdos
  1903.     add.l    #16,sp            * update stack
  1904.     tst.l    d0
  1905.     bmi    io_error
  1906.  
  1907.     move.l    #prg_stk-8,prg_sp    * set program stack pointer
  1908.     move.l    #over,prg_stk-8        * prg stack gate
  1909.     move.l    d0,prg_stk-4        * basepage address
  1910.     rts
  1911.  
  1912. *------------------------------------------------------------------------------*
  1913.  
  1914. io_error:                * message: I/O error
  1915.  
  1916.     lea    io_er_s+17,a0
  1917.     clr.l    d2
  1918.     move.b    d0,d2            * error no
  1919.     neg.b    d2
  1920.     bsr    d2_hx_w            * conversion
  1921.     lea    io_er_s,a0
  1922.     bsr    prt_str
  1923.     bsr    ch_input
  1924.     bra    exit
  1925.  
  1926. *------------------------------------------------------------------------------*
  1927.  
  1928. rev_on:                    * enter in reverse video mode
  1929.  
  1930.     lea    r_on_s,a0
  1931.     bra    prt_str
  1932.  
  1933. *------------------------------------------------------------------------------*
  1934.  
  1935. rev_off:                * exit reverse video mode
  1936.  
  1937.     lea    r_off_s,a0
  1938.     bra    prt_str
  1939.  
  1940. *------------------------------------------------------------------------------*
  1941. *------------------------------------------------------------------------------*
  1942. *------------------------------------------------------------------------------*
  1943.  
  1944. read_chr            * read a char from keyboard
  1945.                 * scan code (hi) + char (lo) read is in d0
  1946.     movem.l    a0,-(sp)    * other register not affected
  1947.     move.w    #1,-(sp)
  1948.     trap    #gemdos        * Cconin
  1949.     addq.l    #2,sp
  1950.     movem.l    (sp)+,a0
  1951.     rts
  1952.  
  1953. *------------------------------------------------------------------------------*
  1954.  
  1955. prt_chr                * print char in d0
  1956.     movem.l    d0/a0,-(sp)    * register not affected
  1957.     move.w    d0,-(sp)
  1958.     move.w    #2,-(sp)
  1959.     trap    #gemdos        * Cconout
  1960.     addq.l    #4,sp
  1961.     movem.l    (sp)+,d0/a0
  1962.     rts
  1963.  
  1964. *------------------------------------------------------------------------------*
  1965.  
  1966. prt_str                * print string located at address a0
  1967.                 * string must be null terminated
  1968.     movem.l    d0/a0,-(sp)    * register not affected
  1969.     move.l    a0,-(sp)
  1970.     move.w    #9,-(sp)
  1971.     trap    #gemdos
  1972.     addq.l    #6,sp
  1973.     movem.l    (sp)+,a0/d0
  1974.     rts
  1975.  
  1976. *------------------------------------------------------------------------------*
  1977.  
  1978. read_str            * read a string of max length d0 (d0<256)
  1979.                 * a0 is the address of return string 
  1980.                 * (null terminated) and must point to a room
  1981.                 * of d0 + 3 bytes
  1982.                 * upon return d0 is the number of char read
  1983.                 * other register not affected
  1984.  
  1985.     move.l    a0,-(sp)    * save buffer address
  1986.     move.b    d0,(a0)        * put the max in the first byte
  1987.     move.l    a0,-(sp)
  1988.     move.w    #$A,-(sp)
  1989.     trap    #gemdos        * Cconrs
  1990.     addq.l    #6,sp
  1991.     clr.l    d0
  1992.     movea.l    (sp),a0        * restore buffer address
  1993.     move.b    1(a0),d0    * number of char actually read
  1994.     beq    read_0        * if no char are read
  1995.     movem.l    d0/a1,-(sp)    * save register
  1996.     lea    2(a0),a1
  1997.     subq.b    #1,d0
  1998. copy_rd    move.b    (a1)+,(a0)+
  1999.     dbra    d0,copy_rd
  2000.     move.b    #0,(a0)        * the null
  2001.     movem.l    (sp)+,d0/a1    * restore register
  2002. read_0    movea.l (sp)+,a0    * restore buffer address
  2003.     rts
  2004.  
  2005. *------------------------------------------------------------------------------*
  2006.  
  2007. ch_input:            * read a char from keyboard, whitout echo 
  2008.                 * scan code (hi) + char (lo) read is in d0
  2009.     movem.l    a0,-(sp)    * other register not affected
  2010.     move.w    #8,-(sp)
  2011.     trap    #gemdos        * Cnecin
  2012.     addq.l    #2,sp
  2013.     movem.l    (sp)+,a0
  2014.     rts
  2015.  
  2016. *------------------------------------------------------------------------------*
  2017.  
  2018. conout    move.w    d0,-(sp)        * char
  2019.     move.w    d1,-(sp)        * device
  2020.     move.w    #3,-(sp)        * function number
  2021.     trap    #bios
  2022.     addq.l    #6,sp            * update stack
  2023.     rts
  2024.  
  2025. *------------------------------------------------------------------------------*
  2026. *----------------------- Exeption handling routine ----------------------------*
  2027. *------------------------------------------------------------------------------*
  2028. excep_new:                * initialise new exception vector
  2029.  
  2030.     lea    exepold,a0        * save area for old exception vector
  2031.     lea    exepnew,a1        * new exception vector
  2032.     movea.l    #8,a2            * begin change at vector 2
  2033.     moveq    #2,d0            * change 3 vector
  2034. exepnlp    move.l    (a2),(a0)+        * store old value
  2035.     move.l    (a1)+,(a2)+        * set new value
  2036.     dbra    d0,exepnlp
  2037.     rts
  2038.  
  2039. excep_old:                * restore exception vector
  2040.  
  2041.     lea    exepold,a0        * save area for old exception vector
  2042.     movea.l    #8,a2            * begin change at vector 2
  2043.     moveq    #2,d0            * change 3 vector
  2044. exepolp    move.l    (a0)+,(a2)+        * restore old value
  2045.     dbra    d0,exepolp
  2046.     rts
  2047.  
  2048. v_bus    lea    s_bus,a0        * bus error
  2049.     moveq    #8,d0
  2050.     bra    do_exep            
  2051.  
  2052. v_adr    lea    s_adr,a0        * address error
  2053.     moveq    #8,d0
  2054.     bra    do_exep            
  2055.  
  2056. v_illeg    lea    s_illeg,a0        * illegal instruction
  2057.     moveq    #0,d0
  2058.     bra    do_exep            
  2059.  
  2060. do_exep    lea    str,a3
  2061.     move.b    #13,(a3)+
  2062.     move.b    #10,(a3)+
  2063.     bsr    copy_s            * error type
  2064.     lea    s_at,a0
  2065.     bsr    copy_s
  2066.     move.l    2(a7,d0.w),d6        * PC at error
  2067.     bsr    hx_$
  2068.     move.b    #' ',(a3)+
  2069.     move.b    #'[',(a3)+
  2070.     movea.l    prg_sp,a0        * prg SP at error
  2071.     move.l    (a0),d6            * pointed value
  2072.     bsr    hx_$
  2073.     move.b    #' ',(a3)+
  2074.     movea.l    prg_sp,a0        * prg SP at error
  2075.     move.l    -4(a0),d6        * previous pointed value
  2076.     bsr    hx_$
  2077.     move.b    #']',(a3)+
  2078.     move.b    #10,(a3)+
  2079.     clr.b    (a3)
  2080.     lea    str,a0            * print
  2081.     bsr    prt_str
  2082.     bra    exit
  2083.  
  2084. *------------------------------------------------------------------------------*
  2085.  
  2086. asc_hx:                    * a char in d0 is converted to his
  2087.                     * hexa value. value is returned in d0
  2088.                     * overflow is set for a non hexa char
  2089.                     * and d0 (.b) is fill with 0.
  2090.                     * other register not affected
  2091.     subi.b    #48,d0
  2092.     bcs    no_v            * '0' or greater
  2093.     cmpi.b    #9,d0
  2094.     bls    hx_ok            * '9' or lower
  2095.     subq.b    #7,d0
  2096.     cmpi.b    #10,d0
  2097.     bcs    no_v            * 'A' or greater
  2098.     cmpi.b    #15,d0
  2099.     bls    hx_ok            * 'F' or lower
  2100.     subi.b    #32,d0
  2101.     cmpi.b    #10,d0
  2102.     bcs    no_v            * 'a' or greater
  2103.     cmpi.b    #15,d0
  2104.     bls    hx_ok            * 'f' or lower
  2105.  
  2106. no_v    clr.b    d0            * zero in d0
  2107.     move    #2,CCR            * set overflow bit
  2108. hx_ok    rts
  2109.  
  2110. *------------------------------------------------------------------------------*
  2111.  
  2112. a_to_hx:                * a null terminated string located
  2113.                     * at a0 is converted to his hexa value
  2114.                     * return at the first non hexa value
  2115.                     * hexa value hold in d1
  2116.                     * other register not affected
  2117.  
  2118.     movem.l d0/a0,-(sp)        * save register
  2119.     moveq    #0,d0
  2120.     moveq    #0,d1
  2121.  
  2122. hx_nxt    move.b    (a0)+,d0        * char in d0
  2123.     beq    a_h_ex            * char is zero ?  then return
  2124.     bsr    asc_hx            * convert in hexa value
  2125.     bvs    a_h_ex            * no hexa value ? then exit
  2126.     lsl.l    #4,d1            * d1=16*d1
  2127.     add.l    d0,d1            * d1=d1+d0
  2128.     bra    hx_nxt            * ready for next char
  2129.  
  2130. a_h_ex    movem.l    (sp)+,d0/a0        * restore register
  2131.     rts
  2132.  
  2133. *------------------------------------------------------------------------------*
  2134.  
  2135. a_to_dec:                * a null terminated string located
  2136.                     * at a0 is converted to his decimal
  2137.                     * value. return at the first non digit
  2138.                     * decimal value hold in d1
  2139.                     * other register not affected
  2140.  
  2141.     movem.l d0/d2/a0,-(sp)        * save register
  2142.     moveq    #0,d0
  2143.     moveq    #0,d1
  2144.  
  2145. dec_nxt    move.b    (a0)+,d0        * char in d0
  2146.     subi.b    #48,d0
  2147.     bmi    a_d_ex            * '0' or greater
  2148.     cmpi.b    #9,d0
  2149.     bgt    a_d_ex            * '9' or lower
  2150.     move.l    d1,d2            * let d1=val, d2=val
  2151.     lsl.l    #1,d2            * d2=2*d2=2*val
  2152.     move.l    d2,d1            * d1=d2=2*val
  2153.     lsl.l    #2,d2            * d2=4*d2=8*val
  2154.     add.l    d2,d1            * d1=d2+d1=10*val
  2155.     add.l    d0,d1            * d1=10*val+d1
  2156.     bra    dec_nxt            * ready for next char
  2157.  
  2158. a_d_ex    movem.l    (sp)+,d0/d2/a0        * restore register
  2159.     rts
  2160.  
  2161. *------------------------------------------------------------------------------*
  2162.  
  2163. hx_$:                    * value d6 to ascii in a3 (updated)
  2164.  
  2165.     move.b    #'$',(a3)+        * $ leader sign for hexa value
  2166.  
  2167. hx_no_$    tst.l    d6            * here, no leader $ sign
  2168.     beq    hx_0
  2169.     lea    temp_s,a0        * temporary storage for the ascii str.
  2170.     move.l    d6,d2
  2171.     bsr    d2_hx_l            * conversion to 8 char
  2172.  
  2173.     moveq    #7,d0            * char counter
  2174.     lea    temp_s,a0
  2175. not_0    cmpi.b    #'0',(a0)+        * find the 1st non '0' char
  2176.     dbne    d0,not_0
  2177.     subq.l    #1,a0            * 1st non '0'
  2178. mv_hx    move.b    (a0)+,(a3)+        * copy the remainning
  2179.     dbra    d0,mv_hx
  2180.     rts
  2181.  
  2182. hx_0    move.b    #'0',(a3)+
  2183.     rts
  2184.  
  2185.  
  2186.  
  2187. *------------------------------------------------------------------------------*
  2188.  
  2189. d2_hx_b:                * d2 byte to hexadecimal ascii in a0
  2190.  
  2191.     moveq    #1,d1            * 2 bytes counter
  2192.     bra    nib_val            * (in d2_hx_l)
  2193.  
  2194. *------------------------------------------------------------------------------*
  2195.  
  2196. d2_hx_w:                * d2 word to hexadecimal ascii in a0
  2197.  
  2198.     moveq    #3,d1            * 4 bytes counter
  2199.     bra    nib_val            * (in d2_hx_l)
  2200.  
  2201. *------------------------------------------------------------------------------*
  2202.  
  2203. d2_hx_l:                * d2 long to hexadecimal ascii in a0
  2204.  
  2205.     moveq    #7,d1            * 8 bytes counter
  2206. nib_val    move.b    d2,d0            * byte value
  2207.     andi.b    #$F,d0            * low nibble
  2208.     bsr    do_nib
  2209.     lsr.l    #4,d2            * ready for the next
  2210.     dbra    d1,nib_val        * loop until d1 > -1
  2211.     rts
  2212.  
  2213. do_nib    addi.b    #48,d0            * ascii digit
  2214.     cmpi.b    #57,d0            * > 9 ?
  2215.     bgt    letter            * no, it is a letter
  2216.     bra    store_c            * store the digit
  2217. letter    addq.b    #7,d0
  2218. store_c    move.b    d0,0(a0,d1.w)
  2219.     rts
  2220.  
  2221. *------------------------------------------------------------------------------*
  2222.  
  2223. adr_hx:                    * a5 address to hexadecimal ascii
  2224.  
  2225.     lea    str+2,a0        * hexa address area
  2226.     move.l    a5,d2
  2227.     bra    d2_hx_l
  2228.     
  2229. *------------------------------------------------------------------------------*
  2230.  
  2231. copy_s:                    * copy null terminated string a0 to a3
  2232.                     * null not copied, a3 updated
  2233.     tst.b    (a0)
  2234.     beq    copy_ex
  2235.     move.b    (a0)+,(a3)+
  2236.     bra    copy_s
  2237. copy_ex    rts
  2238.  
  2239. *------------------------------------------------------------------------------*
  2240. *------------------------ disassembler main routine ---------------------------*
  2241. *------------------------------------------------------------------------------*
  2242. * a5 disassembled address (opcode)
  2243. * a4 extension word (or long) address  
  2244. * a3 disassembled ascii string address
  2245. * d7 register no.
  2246. * d6 hexa. value to display
  2247. * d5 bit 12-15 of opcode
  2248. * d4 size
  2249. * d3 mode
  2250. *------------------------------------------------------------------------------*
  2251. *-------------------------- main driver subroutine ----------------------------*
  2252. *------------------------------------------------------------------------------*
  2253.  
  2254. drv:    bsr    code_m            * first 4 bits of opcode in d5
  2255.  
  2256.     beq    v0000            * addi, xxxi, and test bit family
  2257.     cmpi.b    #%0011,d5
  2258.     ble    _move            * move and movea
  2259.     cmpi.b    #%0100,d5
  2260.     beq    v0100            * chk and one operand instruction
  2261.     cmpi.b    #%0101,d5
  2262.     beq    v0101            * addq, dbcc, scc, subq
  2263.     cmpi.b    #%0110,d5
  2264.     beq    v0110            * bcc, bsr
  2265.     cmpi.b    #%0111,d5
  2266.     beq    v0111            * moveq
  2267.     cmpi.b    #%1000,d5
  2268.     beq    v1000            * divs, divu, or, sbcd
  2269.     cmpi.b    #%1001,d5
  2270.     beq    v1001            * sub, suba, subx
  2271.     cmpi.b    #%1011,d5
  2272.     beq    v1011            * cmp, cmpa, cmpm, eor
  2273.     cmpi.b    #%1100,d5
  2274.     beq    v1100            * abcd, and, exc, muls, mulu
  2275.     cmpi.b    #%1101,d5
  2276.     beq    v1101            * add, adda, addx
  2277.     cmpi.b    #%1110,d5
  2278.     beq    v1110            * rotation and shift familly
  2279.  
  2280.     bra    unknown
  2281.  
  2282. *------------------------------------------------------------------------------*
  2283. *-------------------------- second driver subroutine --------------------------*
  2284. *------------------------------------------------------------------------------*
  2285.  
  2286. v0000    btst    #0,(a5)            * if set -> test bit familly
  2287.     bne    tstbit
  2288.     move.b    (a5),d0
  2289.     lsr.b    #1,d0            * test only bit 9-11
  2290.     cmpi.b    #%100,d0
  2291.     beq    tstbit            * %100 -> test bit familly 
  2292.     bra    xxxi            * other -> xxxi familly
  2293.  
  2294. *------------------------------------------------------------------------------*
  2295.  
  2296. v0100    btst    #0,(a5)            * bit 8 of opcode
  2297.     bne    _chk_lea        * 1: -> chk or lea
  2298.     move.b    1(a5),d4
  2299.     lsr.b    #6,d4            * size on some instruction
  2300.     move.b    (a5),d0
  2301.     lsr.b    #1,d0
  2302.     andi.b    #%111,d0        * bit 9-11 of opcode
  2303.     bne    v0100_1
  2304.     cmpi.b    #3,d4
  2305.     beq    mv_f_SR            * move from SR
  2306.     bra    _negx            * negx
  2307. v0100_1    cmpi.b    #1,d0
  2308.     bne    v0100_2
  2309.     bra    _clr            * clr
  2310. v0100_2    cmpi.b    #2,d0
  2311.     bne    v0100_3
  2312.     cmpi.b    #3,d4
  2313.     beq    mv_CCR            * move to CCR
  2314.     bra    _neg            * neg
  2315. v0100_3    cmpi.b    #3,d0
  2316.     bne    v0100_4
  2317.     cmpi.b    #3,d4
  2318.     beq    mv_t_SR            * move to SR
  2319.     bra    _not            * not
  2320. v0100_4    cmpi.b    #4,d0
  2321.     bne    v0100_5
  2322.     move.w    (a5),d1
  2323.     move.b    d1,d0
  2324.     lsr.w    #6,d1
  2325.     andi.b    #%111,d1        * bit 6-8 of opcode
  2326.     beq    _nbcd            * nbcd
  2327.     cmpi.b    #1,d1
  2328.     bhi    _ext_movem        * ext or movem
  2329.     andi.b    #%00111111,d0        * bit 0-5 of opcode
  2330.     cmpi.b    #%00001000,d0
  2331.     bcs    _swap            * mode 0: -> swap
  2332.     bra    _pea            * mode >1 -> pea
  2333. v0100_5    cmpi.b    #5,d0
  2334.     bne    v0100_6
  2335.     cmpi.b    #3,d4
  2336.     bcs    _tst            * tst
  2337.     cmpi.b    #%11111100,1(a5)
  2338.     beq    _illegal        * illegal
  2339.     bra    _tas            * tas
  2340. v0100_6    cmpi.b    #6,d0
  2341.     bne    v0100_7
  2342.     bra    _movem            * (in _ext_movem)
  2343. v0100_7    move.w    (a5),d1
  2344.     lsr.w    #6,d1
  2345.     andi.b    #%111,d1        * bit 6-8 of opcode
  2346.     cmpi.b    #%010,d1
  2347.     beq    _jsr            * _jsr
  2348.     bhi    _jmp            * _jmp
  2349.     bcs    misc
  2350.  
  2351. misc    move.b    1(a5),d0
  2352.     lsr.b    #3,d0
  2353.     andi.b    #%111,d0        * bit 3-5 of opcode
  2354.     cmpi.b    #%010,d0
  2355.     beq    _link            * link
  2356.     bcs    _trap            * trap
  2357.     cmpi.b    #%011,d0
  2358.     beq    _unlk            * unlk
  2359.     cmpi.b    #%110,d0
  2360.     bcs    mv_USP            * move USP
  2361.     move.b    1(a5),d0        * no operand instruction
  2362.     cmpi.b    #$70,d0
  2363.     bne    misc1
  2364.     lea    k_reset,a0        * reset
  2365.     bra    do_misc
  2366. misc1    cmpi.b    #$71,d0
  2367.     bne    misc2
  2368.     lea    k_nop,a0        * nop
  2369.     bra    do_misc
  2370. misc2    cmpi.b    #$72,d0
  2371.     bne    misc3
  2372.     lea    k_stop,a0        * stop
  2373.     bra    do_misc
  2374. misc3    cmpi.b    #$73,d0
  2375.     bne    misc5
  2376.     lea    k_rte,a0        * rte
  2377.     bra    do_misc
  2378. misc5    cmpi.b    #$75,d0
  2379.     bne    misc6
  2380.     lea    k_rts,a0        * rts
  2381.     bra    do_misc
  2382. misc6    cmpi.b    #$76,d0
  2383.     bne    misc7
  2384.     lea    k_trapv,a0        * trapv
  2385.     bra    do_misc
  2386. misc7    lea    k_rtr,a0
  2387. do_misc    bsr    copy_s
  2388.     bra    term
  2389.  
  2390. *------------------------------------------------------------------------------*
  2391.  
  2392. v0101    move.b    1(a5),d4
  2393.     lsr.b    #6,d4            * size
  2394.     cmpi.b    #%11,d4            * size < 3 mean addq or subq
  2395.     bne    _addq_subq
  2396.     move.b    1(a5),d3        * else dbcc or scc
  2397.     andi.b    #%00111000,d3        * ea
  2398.     cmpi.b    #%00001000,d3
  2399.     bne    _scc            * mode not %001 is for Scc
  2400.     move.b    #'D',(a3)+        * mode %001 is DBcc
  2401.     bsr    v0110            * (go to v0110 for the mnemo)
  2402.     move.b    1(a5),d7        * do register no in DBcc
  2403.     bsr    data_reg
  2404.     move.b    #comma,(a3)+
  2405.     move.w    (a4)+,d6        * get displacement
  2406.     ext.l    d6
  2407.     bra    condis2            * do displacement
  2408.  
  2409. *------------------------------------------------------------------------------*
  2410.      
  2411. v0110    move.b    #'B',(a3)+
  2412.     clr.w    d0
  2413.     move.b    (a5),d0
  2414.     andi.b    #%1111,d0        * condition code
  2415.     cmpi.b    #1,d0            * bf ?
  2416.     beq    cond_bf
  2417.     bcs    cond_bt            * bt
  2418. cond2    lea    cc_code,a0        * other in cc_code table
  2419.     lsl.b    #1,d0            * multiply by 2
  2420.     adda.w    d0,a0
  2421.     move.b    (a0)+,(a3)+        * two char
  2422.     move.b    (a0)+,(a3)+
  2423. condval    move.b    #tab,(a3)+
  2424.     cmpi.b    #%0110,d5        * Bcc or DBcc ?
  2425.     beq    condisp            * if Bcc, continue
  2426.     rts                * else return
  2427.  
  2428. condisp    bsr    val8_16            * get displacement
  2429. condis2    add.l    a5,d6            * next instruction add. + displacment
  2430.     addq.l    #2,d6            * plus 2
  2431.     bsr    hx_$            * to ascii
  2432.     bra    term
  2433.  
  2434. cond_bf    cmpi.b    #%0110,d5        * Bcc or DBcc ?
  2435.     bne    cond_bt            * if DBcc, then dbra
  2436.     move.b    #'S',(a3)+        * else bsr
  2437.     move.b    #'R',(a3)+
  2438.     bra    condval
  2439.  
  2440. cond_bt    move.b    #'R',(a3)+        * bra or dbra
  2441.     move.b    #'A',(a3)+
  2442.     bra    condval
  2443.  
  2444. *------------------------------------------------------------------------------*
  2445.  
  2446. v0111    clr.l    d6
  2447.     lea    k_move,a0
  2448.     bsr    copy_s            * copy keyword
  2449.     move.b    #'Q',(a3)+
  2450.     move.b    #tab,(a3)+
  2451.     move.b    1(a5),d6        * value for moveq
  2452.     move.b    #'#',(a3)+
  2453.     bsr    hx_$
  2454.     move.b    #comma,(a3)+
  2455.     bsr    reg_9_11        * register no
  2456.     bsr    data_reg        * to ascii
  2457.     bra    term
  2458.  
  2459. *------------------------------------------------------------------------------*
  2460.  
  2461. v1000    move.w    (a5),d3
  2462.     lsr.w    #6,d3
  2463.     andi.w    #%111,d3
  2464.     cmpi.b    #%011,d3        * divu        
  2465.     beq    div_mul
  2466.     cmpi.b    #%111,d3        * divs
  2467.     beq    div_mul
  2468.     move.w    (a5),d3
  2469.     andi.w    #%111110000,d3
  2470.     cmpi.w    #%100000000,d3
  2471.     bne    op_md0
  2472.     move.b    #'S',(a3)+        * sbcd
  2473.     bra    _bcd
  2474. op_md0    lea    k_or,a0            * or
  2475. op_md1    bsr    copy_s            * copy keyword
  2476. op_md2    bsr    op_mode
  2477.     bra    term
  2478.  
  2479. *------------------------------------------------------------------------------*
  2480.  
  2481. v1001    lea    k_sub,a0
  2482.     bsr    copy_s            * copy keyword
  2483.     bra    _sub_add
  2484.  
  2485. *------------------------------------------------------------------------------*
  2486.  
  2487. v1011    move.w    (a5),d3
  2488.     lsr.w    #6,d3
  2489.     andi.w    #%111,d3
  2490.     cmpi.b    #%011,d3        * cmpa word        
  2491.     beq    _cmp
  2492.     cmpi.b    #%111,d3        * cmpa long
  2493.     beq    _cmp
  2494.     btst    #2,d3
  2495.     beq    _cmp            * cmp
  2496.     move.b    1(a5),d1
  2497.     and.b    #%00111111,d1
  2498.     cmpi.b    #%00001111,d1
  2499.     bhi    _eor            * eor
  2500.  
  2501.     lea    k_cmp,a0        * now: cmpm
  2502.     bsr    copy_s            * copy keyword
  2503.     move.b    #'M',(a3)+
  2504.     moveq    #%111,d2        * (Ay)+,(Ax)+ and need size id
  2505.     bra    RxRy
  2506.  
  2507. *------------------------------------------------------------------------------*
  2508.  
  2509. v1100    move.w    (a5),d3
  2510.     lsr.w    #6,d3
  2511.     andi.w    #%111,d3
  2512.     cmpi.b    #%011,d3        * mulu        
  2513.     beq    div_mul
  2514.     cmpi.b    #%111,d3        * muls
  2515.     beq    div_mul
  2516.     btst    #0,(a5)
  2517.     beq    _and            * and
  2518.     move.b    1(a5),d3
  2519.     andi.b    #%111111,d3
  2520.     cmpi.b    #%010000,d3        * mode >= 2
  2521.     bcc    _and            * yes, it is and
  2522.     move.b    1(a5),d3
  2523.     cmpi.b    #%1000000,d3
  2524.     bcc    _exg            * exg
  2525.     move.b    #'A',(a3)+        * abcd
  2526.     bra    _bcd
  2527.  
  2528.     lea    k_and,a0
  2529.     bsr    copy_s            * copy keyword
  2530.     bsr    op_mode
  2531.     bra    term
  2532.  
  2533. *------------------------------------------------------------------------------*
  2534.  
  2535. v1101    lea    k_add,a0
  2536.     bsr    copy_s            * copy keyword
  2537.     bra    _sub_add
  2538.  
  2539. v1110    move.b    1(a5),d4
  2540.     lsr.b    #6,d4            * size
  2541.     cmpi.b    #%11,d4            * mean rotation or shift in memory
  2542.     beq    rot_mem
  2543.     move.b    1(a5),d2        * here, register destination
  2544.     lsr.b    #3,d2            * name id
  2545.     bra    rot_id
  2546.  
  2547. rot_mem    move.b    (a5),d2            * and here memory destination
  2548.     lsr.b    #1,d2
  2549.  
  2550. rot_id    andi.b    #%11,d2
  2551.     tst.b    d2
  2552.     bne    rot_1
  2553.     move.b    #'A',(a3)+        * asl, asr
  2554.     move.b    #'S',(a3)+
  2555.     bra    rotname
  2556. rot_1    cmpi.b    #1,d2
  2557.     bne    rot_2
  2558.     move.b    #'L',(a3)+        * lsl, lsr
  2559.     move.b    #'S',(a3)+
  2560.     bra    rotname
  2561. rot_2    cmpi.b    #2,d2
  2562.     bne    rot_3
  2563.     move.b    #'R',(a3)+        * rol, ror
  2564.     move.b    #'O',(a3)+
  2565.     move.b    #'X',(a3)+
  2566.     bra    rotname
  2567. rot_3    move.b    #'R',(a3)+        * roxl, roxr
  2568.     move.b    #'O',(a3)+
  2569.  
  2570.  
  2571. rotname    btst    #0,(a5)            * direction
  2572.     bne    rotleft
  2573.     move.b    #'R',(a3)+        * right direction
  2574.     bra    rot_sz
  2575. rotleft    move.b    #'L',(a3)+
  2576.  
  2577. rot_sz    cmpi.b    #%11,d4
  2578.     bne    rot_reg            * register destination: need size
  2579.     bra    tab_ea            * memory destination, no size
  2580.  
  2581. rot_reg    bsr    do_size
  2582.     bsr    reg_9_11        * bit 9-11 in d7
  2583.     btst    #5,1(a5)        * source flag
  2584.     beq    rot_imm            * 0: -> immediat
  2585.     bsr    data_reg        * 1: -> Dx
  2586.     bra    rot_Dy
  2587.  
  2588. rot_imm    move.b    d7,d6            * source is immediat value in bit 9-11
  2589.     bne    r_imm_2
  2590.     moveq    #8,d6            * 0 mean 8 for this form
  2591. r_imm_2    move.b    #'#',(a3)+
  2592.     addi.b    #'0',d6
  2593.     move.b    d6,(a3)+        * immediate value
  2594.  
  2595. rot_Dy    move.b    #comma,(a3)+
  2596.     move.b    1(a5),d7        * destination register
  2597.     bsr    data_reg
  2598.     bra    term
  2599.  
  2600. *------------------------------------------------------------------------------*
  2601. *------------------------------------------------------------------------------*
  2602. *---------------------------- addressing mode ---------------------------------*
  2603. *------------------------------------------------------------------------------*
  2604.  
  2605. reg_out:                * register no (d7) to ascii no in a3
  2606.                     * a3 updated
  2607.     andi.b    #7,d7            * only last 4 bits
  2608.     addi.b    #'0',d7            * now ascii digit
  2609.     move.b    d7,(a3)+        * store char
  2610.     rts
  2611.  
  2612. *------------------------------------------------------------------------------*
  2613.  
  2614. data_reg:                * data register to ascii in a3
  2615.                     * [Dn], d7=n, a3 updated
  2616.     move.b    #'D',(a3)+
  2617.     bra    reg_out
  2618.  
  2619. *------------------------------------------------------------------------------*
  2620.  
  2621. adr_reg:                * address register to ascii in a3
  2622.                     * [An], d7=n, a3 updated
  2623.     move.b    #'A',(a3)+
  2624.     bra    reg_out
  2625.  
  2626. *------------------------------------------------------------------------------*
  2627.  
  2628. indirect:                * address register indirect
  2629.                     * to ascii in a3 (updated)
  2630.                     * [(An)], n=d7
  2631.     move.b    #'(',(a3)+
  2632.     bsr    adr_reg
  2633.     move.b    #')',(a3)+
  2634.     rts
  2635.  
  2636. *------------------------------------------------------------------------------*
  2637.  
  2638. post_inc:                * address register indirect post-
  2639.                     * increment to ascii in a3 (updated)
  2640.                     * [(An)+], n=d7
  2641.     bsr    indirect
  2642.     move.b    #'+',(a3)+
  2643.     rts
  2644.  
  2645. *------------------------------------------------------------------------------*
  2646.  
  2647. pre_dec:                * address register indirect pre-
  2648.                     * decrement to ascii in a3 (updated)
  2649.                     * [-(An)], n=d7
  2650.     move.b    #'-',(a3)+
  2651.     bra    indirect
  2652.  
  2653. *------------------------------------------------------------------------------*
  2654.  
  2655. indir_disp:                * address register indirect with
  2656.                     * displacement to ascii in a3 (updated)
  2657.                     * [d(An)], n=d7, d=d6 
  2658.                     * extension word -> a6 (a4 updated)
  2659.     clr.l    d6
  2660.     move.w    (a4)+,d6        * displacement value
  2661.     bsr    hx_$            * displacement in hexa
  2662.     bra    indirect        * register no
  2663.  
  2664. *------------------------------------------------------------------------------*
  2665.  
  2666. index_disp:                * address register indirect with
  2667.                     * displacement and index to ascii in a3
  2668.                     * (updated). d(An,Rm.sz). n=d7, d=d6
  2669.                     * extension word -> a4 (updated)
  2670.     clr.l    d6
  2671.     move.b    1(a4),d6        * displacement value
  2672.     bsr    hx_$            * displacement to ascii
  2673.     move.b    #'(',(a3)+
  2674.     cmpi.b    #8,d7            * register no 8 mean PC
  2675.     beq    indx_PC
  2676.     bsr    adr_reg            * An to ascii
  2677. indx_nx    move.b    #comma,(A3)+
  2678.     move.b    (a4),d7
  2679.     lsr.b    #4,d7            * m value (bit 0-2)
  2680.     btst    #7,(a4)            * R: 0 -> D, 1 -> A
  2681.     beq    is_data
  2682.     bsr    adr_reg            * Rm to ascii
  2683.     bra    mk_size
  2684. is_data    bsr    data_reg        * Rm to ascii
  2685.  
  2686. mk_size    move.b    #'.',(a3)+
  2687.     btst.b    #3,(a4)            * .L or .W to ascii
  2688.     beq    is_word            * size: 0 -> word, 1 -> long
  2689.     move.b    #'L',(a3)+
  2690.     bra    do_sz
  2691. is_word    move.b    #'W',(a3)+
  2692. do_sz    move.b    #')',(a3)+        * end char ')'
  2693.     addq.l    #2,a4            * update a4
  2694.     rts
  2695.  
  2696. indx_PC    move.b    #'P',(a3)+        * pc relative with index and disp.
  2697.     move.b    #'C',(a3)+
  2698.     bra    indx_nx
  2699.  
  2700. *------------------------------------------------------------------------------*
  2701.  
  2702. pc_disp:                * program counter relative with
  2703.                     * displacement to ascii in a3 (updated)
  2704.                     * [d(PC)] displacement d=d1
  2705.                     * extension word -> a4 (updated)
  2706.     clr.l    d6
  2707.     move.w    (a4)+,d6        * displacement value
  2708.     bsr    hx_$            * displacement in hexa
  2709.     move.b    #'(',(a3)+
  2710.     move.b    #'P',(a3)+
  2711.     move.b    #'C',(a3)+
  2712.     move.b    #')',(a3)+
  2713.     rts
  2714.  
  2715. *------------------------------------------------------------------------------*
  2716.  
  2717. pc_index:                * program counter relative with
  2718.                     * displacement and index to ascii in a3
  2719.                     * (updated). d(PC,Rm.sz). d=d6
  2720.                     * extension word -> a4 (updated)
  2721.  
  2722.     moveq    #8,d7            * special value in index_disp
  2723.     bra    index_disp
  2724.  
  2725. *------------------------------------------------------------------------------*
  2726.  
  2727. abs_w:                    * absolute short addressing (in a4)
  2728.                     * [$1234] a3, a4 updated
  2729.     clr.l    d6
  2730.     move.w    (a4)+,d6
  2731.     bra    hx_$
  2732.  
  2733. *------------------------------------------------------------------------------*
  2734.  
  2735. abs_l:                    * absolute long addressing (in a4)
  2736.                     * [$123456] a3, a4 updated
  2737.     move.l    (a4)+,d6        
  2738.     bra    hx_$
  2739.  
  2740. *------------------------------------------------------------------------------*
  2741.  
  2742. immediat:                * immediat value to ascii in a3
  2743.                     * [#$1234] a3,a4 updated
  2744.     clr.l    d6
  2745.     move.b    #'#',(a3)+
  2746.     cmpi.b    #1,d4            * hold size
  2747.     beq    imm1
  2748.     bhi    imm2
  2749.     move.w    (a4)+,d6
  2750.     andi.w    #$ff,d6            * byte value, low byte of word
  2751.     bra    hx_$
  2752.  
  2753. imm1    move.w    (a4)+,d6        * word value (update a4)
  2754.     bra    hx_$
  2755.  
  2756. imm2    move.l    (a4)+,d6        * long value (update a4)
  2757.     bra    hx_$
  2758.  
  2759. *------------------------------------------------------------------------------*
  2760.  
  2761. unknown:                * invalid opcode
  2762.  
  2763.     lea    str+mnemo,a3
  2764.     move.b    #'?',(a3)+
  2765.     move.b    #0,(a3)+    
  2766.     rts
  2767.  
  2768. *------------------------------------------------------------------------------*
  2769. *--------------------- addressiong mode combination ---------------------------*
  2770. *------------------------------------------------------------------------------*
  2771.  
  2772. reg_9_11:                * register in bit 9-11 of opcode in d7
  2773.  
  2774.     move.b    (a5),d7
  2775.     lsr.b    #1,d7
  2776.     andi.b    #%111,d7
  2777.     rts
  2778.  
  2779. *------------------------------------------------------------------------------*
  2780.  
  2781. ea_0_5:                    * address effective in bit 0-5 of (a5)
  2782.                     * extension in (a4)
  2783.     clr.w    d7
  2784.     clr.w    d3
  2785.     move.b    1(a5),d7
  2786.     move.b    d7,d3
  2787.     andi.b    #%111000,d3        * mode*8 (in bit 3-5)
  2788.     lsr.b    #3,d3            * mode
  2789.     andi.b    #%111,d7        * register (go to do_md_rg)
  2790.  
  2791. *------------------------------------------------------------------------------*
  2792.  
  2793. do_md_rg:                * do addressing mode in d3, reg in d7
  2794.  
  2795.  
  2796.     lea    mode_tb,a0
  2797.     andi.w    #7,d3
  2798.     lsl.w    #2,d3            * mode mult 4, table offset
  2799.     adda.w    d3,a0
  2800.     movea.l    (a0),a1
  2801.     jmp    (a1)            * vector table for each mode and reg
  2802.  
  2803. tab_ea    move.b    #tab,(a3)+        * tab separator
  2804.     bsr    ea_0_5            * do effective address
  2805.     bra    term
  2806.  
  2807.  
  2808. com_ea    move.b    #comma,(a3)+        * comma separator
  2809.     bsr    ea_0_5            * do effective address
  2810.     bra    term
  2811.  
  2812.  
  2813. *------------------------------------------------------------------------------*
  2814.  
  2815. mode7:                    * mode 7 routine driver
  2816.  
  2817.     lea    md7_tb,a0
  2818.     andi.w    #7,d7
  2819.     lsl.w    #2,d7            * mult by 4, offset table
  2820.     adda.w    d7,a0
  2821.     movea.l    (a0),a1
  2822.     jmp    (a1)
  2823.  
  2824. *------------------------------------------------------------------------------*
  2825.  
  2826. code_m:                    * bits 12-16 in d5 for mnemotechnics
  2827.                     * codes
  2828.     move.b    (a5),d5
  2829.     lsr.b    #4,d5
  2830.     rts
  2831.  
  2832. *------------------------------------------------------------------------------*
  2833.  
  2834. do_size:                * .B, .W, .L according to value d4
  2835.                     * (0,1,2), a3 updated
  2836.     move.b    #'.',(a3)+
  2837.     andi.b    #%11,d4
  2838.     bne    do1
  2839.     move.b    #'B',(a3)+        * d4=0
  2840.     move.b    #tab,(a3)+
  2841.     rts
  2842.  
  2843. do1    cmpi.b    #1,d4
  2844.     bne    do2
  2845.     move.b    #'W',(a3)+        * d4=1
  2846.     move.b    #tab,(a3)+
  2847.     rts
  2848.  
  2849. do2    move.b    #'L',(a3)+        * d4=2
  2850.     move.b    #tab,(a3)+
  2851.     rts
  2852.  
  2853. *------------------------------------------------------------------------------*
  2854.  
  2855. _sub_add:                * do sub, suba, subx, add, adda, addx
  2856.  
  2857.     btst    #0,(a5)            * bit 8 clear ?
  2858.     beq    op_md2            * go op_mode (in v1000)
  2859.     move.b    1(a5),d3
  2860.     cmpi.b    #%11000000,d3
  2861.     bcc    op_md2            * suba or adda (long)
  2862.     andi.b    #%111111,d3
  2863.     cmpi.b    #%010000,d3        * mode is > 1 ?
  2864.     bcc    op_md2            * then it is op_mode (in v1000)
  2865.     move.b    #'X',(a3)+        * else it is subx or addx
  2866.     move.b    d3,d2
  2867.     lsr.b    #3,d2            * 0: -> dy,dx     1: -> -(Ay),-(Ax)
  2868.     ori.b    #%10,d2            * need size id
  2869.     bra    RxRy
  2870.  
  2871. *------------------------------------------------------------------------------*
  2872.  
  2873. RxRy:                    * used in abcd, cmpm, exc, sbcd
  2874.  
  2875.     btst    #1,d2            * need size id ?
  2876.     bne    RxRy_sz
  2877.     move.b    #tab,(a3)+
  2878.  
  2879. do_RxRy    move.b    (a5),d7
  2880.     lsr.b    #1,d7            * Rx
  2881.     move.w    d7,-(sp)
  2882.     move.b    1(a5),d7        * Ry
  2883.     btst    #0,d2            * R=A ?
  2884.     bne    AxAy
  2885.  
  2886.     bsr    data_reg        * Dy,Dx
  2887.     move.w    (sp)+,d7
  2888.     move.b    #comma,(a3)+
  2889.     bsr    data_reg
  2890.     bra    term
  2891.  
  2892. AxAy    btst    #2,d2            * -(A?) or (A?)+
  2893.     bne    Aplus
  2894.     bsr    pre_dec            * -(Ay),-(Ax)
  2895.     move.w    (sp)+,d7
  2896.     move.b    #comma,(a3)+
  2897.     bsr    pre_dec
  2898.     bra    term
  2899.  
  2900. Aplus    bsr    post_inc        * (Ay)+,(Ax)+
  2901.     move.w    (sp)+,d7
  2902.     move.b    #comma,(a3)+
  2903.     bsr    post_inc
  2904.     bra    term
  2905.  
  2906. RxRy_sz    move.b    1(a5),d4
  2907.     lsr.b    #6,d4            * size
  2908.     bsr    do_size
  2909.     bra    do_RxRy
  2910.  
  2911. *------------------------------------------------------------------------------*
  2912.  
  2913. op_mode:                * op_mode in bit 6-8
  2914.                     * used in add, and, cmp, eor, or, sub
  2915.     move.w    (a5),d3
  2916.     lsr.w    #6,d3
  2917.     andi.w    #%111,d3        * op-mode
  2918.     cmpi.b    #%011,d3
  2919.     bne    op_m1
  2920.     moveq    #1,d4            * word size
  2921.     bra    op_m3
  2922. op_m1    cmpi.b    #%111,d3
  2923.     bne    op_m2
  2924.     moveq    #2,d4            * long size
  2925.     bra    op_m3
  2926. op_m2    move.b    d3,d4
  2927.     andi.b    #%11,d4            * size for mode with Dn
  2928.     lsr.b    #2,d3            * mode, 0: ea -> Dn, 1: Dn -> ea
  2929.     bra    op_m4
  2930.  
  2931. op_m3    moveq    #2,d3            * mode ea -> An
  2932.     move.b    #'A',(a3)+
  2933. op_m4    bsr    do_size            * .B, .W or .L
  2934.  
  2935. ea_Rn    bsr    reg_9_11        * adr or data register no
  2936.     cmpi.b    #1,d3
  2937.     beq    Dn_ea
  2938.     move.w    d7,-(sp)        * save register no
  2939.     move.w    d3,-(sp)        * save mode
  2940.     bsr    ea_0_5
  2941.     move.w    (sp)+,d3        * restore mode
  2942.     move.w    (sp)+,d7        * restore register no
  2943.     move.b    #comma,(a3)+
  2944.     tst.b    d3
  2945.     beq    data_reg        * ea -> Dn
  2946.     bra    adr_reg            * ea -> An
  2947.  
  2948. Dn_ea    bsr    data_reg        * Dn -> ea
  2949.     move.b    #comma,(a3)+
  2950.     bra    ea_0_5
  2951.  
  2952. *------------------------------------------------------------------------------*
  2953.  
  2954. val8_16:                * used in Bcc, DBcc, addq, subq
  2955.                     * value (in low byte of the op-code
  2956.     clr.l    d6            * or in the next word) to d6
  2957.     move.b    1(a5),d6
  2958.     ext.w    d6
  2959.     bne    v8_16ex            * if non_zero, displacement is 8 bits
  2960.     move.w    (a4)+,d6        * else disp is 16 bits in next word
  2961. v8_16ex    ext.l    d6
  2962.     rts
  2963.  
  2964. *------------------------------------------------------------------------------*
  2965.  
  2966. sz_ea:                    * used in clr, neg, negx, tst
  2967.  
  2968.     bsr    copy_s            * copy keyword
  2969.     move.b    1(a5),d4
  2970.     lsr.b    #6,d4            * size
  2971.     bsr    do_size
  2972.     bsr    ea_0_5            * do ea
  2973.     bra    term
  2974.  
  2975. *------------------------------------------------------------------------------*
  2976. *----------------------------- do keyword -------------------------------------*
  2977. *------------------------------------------------------------------------------*
  2978.  
  2979. _exg:                    * mnemo. for exc Rx,Ry
  2980.  
  2981.     lea    k_exg,a0
  2982.     bsr    copy_s            * copy keyword
  2983.     move.b    #tab,(a3)+
  2984.     move.b    1(a5),d3
  2985.     lsr.b    #3,d3            * mode
  2986.     move.b    (a5),d7
  2987.     lsr.b    #1,d7            * Rx
  2988.     cmpi.b    #%01001,d3
  2989.     bne    _exg_Dx
  2990.     bsr    adr_reg            * Rx is address register
  2991.     bra    _exg_Ry
  2992. _exg_Dx    bsr    data_reg        * Rx is data register
  2993. _exg_Ry    move.b    #comma,(a3)+
  2994.     move.b    1(a5),d7        * Ry
  2995.     btst    #0,d3
  2996.     beq    _exg_Dy
  2997.     bsr    adr_reg            * Ry is address register
  2998.     bra    term
  2999. _exg_Dy    bsr    data_reg        * Ry is data register
  3000.     bra    term
  3001.  
  3002. *------------------------------------------------------------------------------*
  3003.  
  3004. _and:                    * mnemo. for and
  3005.     lea    k_and,a0
  3006.     bra    op_md1            * go op-mode (in v1000)
  3007.  
  3008. *------------------------------------------------------------------------------*
  3009.  
  3010. _cmp:                    * mnemo. for cmp and cmpa
  3011.     lea    k_cmp,a0
  3012.     bra    op_md1            * go op-mode (in v1000)
  3013.  
  3014. *------------------------------------------------------------------------------*
  3015.  
  3016. _eor:                    * mnemo. eor
  3017.  
  3018.     lea    k_eor,a0
  3019.     bra    op_md1            * go op-mode (in v1000)
  3020.  
  3021. *------------------------------------------------------------------------------*
  3022.  
  3023. _bcd                    * sbcd, abcd
  3024.     lea    k_bcd,a0
  3025.     bsr    copy_s            * copy keyword
  3026.     move.b    1(a5),d2
  3027.     lsr.b    #3,d2            * 0: -> dy,dx     1: -> -(Ay),-(Ax)
  3028.     bra    RxRy            * (no need size id: bit 1 clear)
  3029.  
  3030. *------------------------------------------------------------------------------*
  3031.  
  3032. div_mul:                * mnemo. for divs, divu, muls, mulu
  3033.  
  3034.     cmpi.b    #%1000,d5
  3035.     beq    _div
  3036.     lea    k_mul,a0        * mul
  3037.     bsr    copy_s            * copy keyword
  3038.     bra    u_s
  3039. _div    lea    k_div,a0        * div
  3040.     bsr    copy_s            * copy keyword
  3041. u_s    cmpi.b    #%111,d3
  3042.     bne    is_u
  3043.     move.b    #'S',(a3)+        * ___s
  3044.     bra    do_dvml
  3045. is_u    move.b    #'U',(a3)+        * ___u
  3046. do_dvml    move.b    #tab,(a3)+
  3047.     moveq    #1,d4            * size operand is word
  3048.     moveq    #0,d3            * mode 1 (R=D) in ea_Rn (see op_mode)
  3049.     bsr    ea_Rn
  3050.     bra    term
  3051.  
  3052. *------------------------------------------------------------------------------*
  3053.  
  3054. _movep:                    * mnemo. for movep
  3055.  
  3056.     lea    str+mnemo,a3        * reset start ascii address
  3057.     lea    k_move,a0
  3058.     bsr    copy_s            * copy keyword
  3059.     move.b    #'P',(a3)+
  3060.  
  3061.     move.w    (a5),d3
  3062.     lsr.w    #6,d3
  3063.     andi.b    #%011,d3
  3064.     move.b    d3,d4
  3065.     andi.b    #$001,d4
  3066.     addq.b    #1,d4            * size
  3067.     bsr    do_size
  3068.     lsr.b    #1,d3            * mode:    0: -> Dn, 1: -> d(An)
  3069.     beq    to_Dn
  3070.  
  3071.     bsr    reg_9_11        * mode 1:  Dn -> d(Am)
  3072.     bsr    data_reg
  3073.     move.b    #comma,(a3)+
  3074.     move.b    1(a5),d7        * address register (bit 0-2)
  3075.     bsr    indir_disp
  3076.     bra    term
  3077.  
  3078. to_Dn    move.b    1(a5),d7        * mode 0:  d(An) -> Dm
  3079.     bsr    indir_disp
  3080.     move.b    #comma,(a3)+
  3081.     bsr    reg_9_11
  3082.     bsr    data_reg
  3083.     bra    term
  3084.  
  3085. *------------------------------------------------------------------------------*
  3086.  
  3087. tstbit:                    * mnemo. for test bit familly
  3088.  
  3089.     move.b    #'B',(a3)+
  3090.     move.w    (a5),d1
  3091.     lsr.w    #6,d1
  3092.     andi.b    #%11,d1            * test only bit 6-7
  3093.     bne    tstb1
  3094.     lea    k_tst,a0
  3095.     bsr    copy_s            * copy keyword
  3096.     bra    do_tstb
  3097. tstb1    cmpi.b    #1,d1
  3098.     bne    tstb2
  3099.     lea    k_chg,a0
  3100.     bsr    copy_s            * copy keyword
  3101.     bra    do_tstb
  3102. tstb2    cmpi.b    #2,d1
  3103.     bne    tstb3
  3104.     lea    k_clr,a0
  3105.     bsr    copy_s            * copy keyword
  3106.     bra    do_tstb
  3107. tstb3    cmpi.b    #3,d1
  3108.     bne    unknown
  3109.     lea    k_set,a0
  3110.     bsr    copy_s            * copy keyword
  3111.  
  3112. do_tstb    move.b    #tab,(a3)+
  3113.     btst    #0,(a5)            * if set -> tested bit in Dn
  3114.     bne    tstbreg
  3115.     moveq    #0,d4            * size
  3116.     bsr    immediat        * else tested is immediat value
  3117.     bra    tstb_ea
  3118. tstbreg    move.w    (a5),d1            * mode %001 is a special meanning
  3119.     andi.w    #%111000,d1
  3120.     cmpi.w    #%001000,d1
  3121.     beq    _movep 
  3122.     bsr    reg_9_11        * take register no
  3123.     bsr    data_reg
  3124. tstb_ea    bra    com_ea            * do ea
  3125.  
  3126. *------------------------------------------------------------------------------*
  3127.  
  3128. xxxi:                    * mnemo. for xxxi familly
  3129.  
  3130.     tst.b    d0
  3131.     bne    xxx1
  3132.     lea    k_or,a0
  3133.     bra    do_xxxi            * ori
  3134. xxx1    cmpi.b    #1,d0
  3135.     bne    xxx2
  3136.     lea    k_and,a0
  3137.     bra    do_xxxi            * andi
  3138. xxx2    cmpi.b    #2,d0
  3139.     bne    xxx3
  3140.     lea    k_sub,a0
  3141.     bra    do_xxxi            * subi
  3142. xxx3    cmpi.b    #3,d0
  3143.     bne    xxx5
  3144.     lea    k_add,a0
  3145.     bra    do_xxxi            * addi
  3146. xxx5    cmpi.b    #5,d0
  3147.     bne    xxx6
  3148.     lea    k_eor,a0
  3149.     bra    do_xxxi            * eori
  3150. xxx6    cmpi.b    #6,d0
  3151.     bne    unknown
  3152.     lea    k_cmp,a0        * cmpi
  3153.  
  3154. do_xxxi    bsr    copy_s            * copy keyword
  3155.     move.b    #'I',(a3)+
  3156.     move.b    1(a5),d3        * test for CCR or SR
  3157.     move.b    d3,d4
  3158.     lsr.b    #6,d4            * size
  3159.     andi.b    #%00111111,d3
  3160.     cmpi.b    #%00111100,d3        * ea for CCR or SR
  3161.     beq    s_cc_ri
  3162.     bsr    do_size
  3163.     bsr    immediat
  3164.     bra    com_ea            * do ea
  3165.  
  3166. s_cc_ri move.b    #tab,(a3)+        * to CCR or to SR
  3167.     bsr    immediat
  3168.     move.b    #comma,(a3)+
  3169.     cmpi.b    #1,d4
  3170.     beq    is_ccr
  3171.     bsr    do_CCR
  3172.     bra    term
  3173. is_ccr    bsr    do_SR
  3174.     bra    term
  3175.     
  3176. do_CCR    lea    k_ccr,a0
  3177.     bra    copy_s            * copy keyword
  3178.  
  3179. do_SR    lea    k_sr,a0
  3180.     bra    copy_s            * copy keyword
  3181.  
  3182. *------------------------------------------------------------------------------*
  3183.  
  3184. _move:                    * mnemo. for move
  3185.     lea    k_move,a0
  3186.     bsr    copy_s            * copy keyword
  3187.     move.w    (a5),d3
  3188.     lsr.w    #6,d3
  3189.     andi.w    #%111,d3        * destination mode
  3190.     cmpi.w    #%001,d3        * move or movea ?
  3191.     bne    mv_sz
  3192.     move.b    #'A',(a3)+
  3193. mv_sz    move.b    d5,d4            * size
  3194.     cmpi.b    #2,d4
  3195.     beq    sz_move            * .L
  3196.     bgt    w_move
  3197.     moveq    #0,d4            * .B
  3198. sz_move    bsr    do_size
  3199.     move.w    d3,-(sp)        * save dest. mode
  3200.     bsr    ea_0_5            * source to ascii
  3201.     move.b    #comma,(a3)+
  3202.     move.w    (sp)+,d3        * restore dest. mode
  3203.     move.b    (a5),d7
  3204.     lsr.b    #1,d7            * destination register
  3205.     andi.b    #%111,d7
  3206.     bsr    do_md_rg        * destination to ascii
  3207.     bra    term            * exit
  3208.  
  3209. w_move    moveq    #1,d4            * .W
  3210.     bra    sz_move
  3211.  
  3212. *------------------------------------------------------------------------------*
  3213.  
  3214. _addq_subq:                * mnemo. for addq, subq
  3215.  
  3216.     clr.l    d6
  3217.     move.b    (a5),d6
  3218.     btst    #0,d6            * 0: -> addq,  1: -> subq
  3219.     bne    _subq
  3220.     lea    k_add,a0
  3221.     bra    ___q
  3222. _subq    lea    k_sub,a0
  3223. ___q    bsr    copy_s            * copy keyword
  3224.     move.b    #'Q',(a3)+
  3225.     bsr    do_size
  3226.     move.b    #'#',(a3)+
  3227.     lsr.b    #1,d6
  3228.     andi.b    #%111,d6        * immediat value
  3229.     bsr    hx_$
  3230.     bra    com_ea            * do ea
  3231.  
  3232. *------------------------------------------------------------------------------*
  3233.  
  3234. _scc:                    * mnemo. for Scc
  3235.  
  3236.     move.b    #'S',(a3)+
  3237.     clr.w    d0
  3238.     move.b    (a5),d0
  3239.     andi.b    #%1111,d0        * condition code
  3240.     lea    cc_code,a0        * other in cc_code table
  3241.     lsl.b    #1,d0            * multiply by 2
  3242.     adda.w    d0,a0
  3243.     move.b    (a0)+,(a3)+        * two char
  3244.     move.b    (a0)+,(a3)+
  3245.     move.b    #tab,(a3)+
  3246.     bsr    ea_0_5
  3247.     bra    term
  3248.  
  3249. *------------------------------------------------------------------------------*
  3250.  
  3251. _trap:                    * mnemo. for trap
  3252.  
  3253.     lea    k_trap,a0
  3254.     bsr    copy_s            * copy keyword
  3255.     move.b    #tab,(a3)+
  3256.     move.b    #'#',(a3)+
  3257.     clr.l    d6
  3258.     move.b    1(a5),d6
  3259.     andi.b    #%1111,d6        * vector no.
  3260.     bsr    hx_$
  3261.     bra    term
  3262.  
  3263. *------------------------------------------------------------------------------*
  3264.  
  3265. _jmp:                    * mnemo. for jmp
  3266.  
  3267.     lea    k_jmp,a0
  3268.     bsr    copy_s            * copy keyword
  3269.     bra    tab_ea            * ea
  3270.  
  3271. *------------------------------------------------------------------------------*
  3272.  
  3273. _jsr:                    * mnemo. for jsr
  3274.  
  3275.     lea    k_jsr,a0
  3276.     bsr    copy_s            * copy keyword
  3277.     bra    tab_ea            * ea
  3278.  
  3279. *------------------------------------------------------------------------------*
  3280.  
  3281. _unlk:                    * mnemo. for unlk
  3282.  
  3283.     lea    k_unlk,a0
  3284.     bsr    copy_s            * copy keyword
  3285.     move.b    1(a5),d7        * register no.
  3286.     move.b    #tab,(a3)+
  3287.     bsr    adr_reg            * address register
  3288.     bra    term
  3289.  
  3290. *------------------------------------------------------------------------------*
  3291.  
  3292. _link:                    * mnemo. for link
  3293.  
  3294.     lea    k_link,a0
  3295. tab_An    bsr    copy_s            * copy keyword
  3296.     move.b    1(a5),d7        * register no.
  3297.     move.b    #tab,(a3)+
  3298.     bsr    adr_reg            * address register
  3299.     move.b    #comma,(a3)+
  3300.     moveq    #1,d4            * size for immediat
  3301.     bsr    immediat
  3302.     bra    term
  3303.  
  3304. *------------------------------------------------------------------------------*
  3305.  
  3306. _illegal:                * mnemo. for illegal
  3307.  
  3308.     lea    k_illg,a0
  3309.     bsr    copy_s            * copy keyword
  3310.     bra    term
  3311.  
  3312. *------------------------------------------------------------------------------*
  3313.  
  3314. _tas:                    * mnemo. for tas
  3315.  
  3316.     lea    k_tas,a0
  3317.     bsr    copy_s            * copy keyword
  3318.     bra    tab_ea            * ea
  3319.  
  3320. *------------------------------------------------------------------------------*
  3321.  
  3322. _pea:                    * mnemo. for pea
  3323.  
  3324.     lea    k_pea,a0
  3325.     bsr    copy_s            * copy keyword
  3326.     bra    tab_ea            * ea
  3327.  
  3328. *------------------------------------------------------------------------------*
  3329.  
  3330. _swap:                    * mnemo. for swap
  3331.  
  3332.     lea    k_swap,a0
  3333.     bsr    copy_s            * copy keyword
  3334.     move.b    1(a5),d7        * register no.
  3335.     move.b    #tab,(a3)+
  3336.     bsr    data_reg        * data register
  3337.     bra    term
  3338.  
  3339. *------------------------------------------------------------------------------*
  3340.  
  3341. _ext_movem:                * mnemo. for ext or movem
  3342.  
  3343.     move.b    1(a5),d0
  3344.     move.b    d0,d4
  3345.     lsr.b    #6,d4
  3346.     subq.b    #1,d4            * size
  3347.  
  3348.     andi.b    #%111111,d0        * ae
  3349.     cmpi.b    #%001000,d0
  3350.     bcs    _ext            * ae = data register is for _ext only
  3351.  
  3352. *------------------------------------------------------------------------------*
  3353.  
  3354. _movem    lea    k_move,a0
  3355.     bsr    copy_s            * copy keyword
  3356.     move.b    #'M',(a3)+
  3357.     bsr    do_size            * .L or .W
  3358.     move.w    (a4)+,d2        * register mask
  3359.     btst    #2,(a5)            * direction
  3360.     bne    _movem1
  3361.  
  3362.     move.b    1(a5),d1        * type: movem d1-d5,-(a7)
  3363.     andi.b    #%111000,d1
  3364.     cmpi.b    #%100000,d1        * pre-decrement mode ?
  3365.     bne    _movem0            * yes, no need mask inversion
  3366.     bsr    inv_bit            * bit 0 become bit 15, etc
  3367.     move.w    d1,d2
  3368. _movem0    bsr    mask
  3369.     bsr    com_ea
  3370.     bra    term
  3371.  
  3372. _movem1 bsr    ea_0_5            * type: movem (a7)+,d1-d5
  3373.     move.b    #comma,(a3)+
  3374.     bsr    mask
  3375.     bra    term
  3376.  
  3377. *------------------------------------------------------------------------------*
  3378.  
  3379. inv_bit:                * inverse word d2 (mirror image) to d1
  3380.  
  3381.     moveq    #15,d0            * bit counter
  3382. do_inv    lsr.w    #1,d2            * test bit
  3383.     bcs    inv_1
  3384.     bclr    d0,d1            * clear the bit
  3385.     dbra    d0,do_inv
  3386.     rts
  3387.  
  3388. inv_1    bset    d0,d1            * set the bit
  3389.     dbra    d0,do_inv
  3390.     rts
  3391.  
  3392. *------------------------------------------------------------------------------*
  3393.  
  3394. mask:                    * mnemo register mask in movem
  3395.  
  3396.     moveq    #-1,d3            * bit counter
  3397.     clr.b    d1            * not first time flag
  3398.  
  3399. mask0    addq.b    #1,d3
  3400.     cmpi.b    #15,d3            * last bit ?
  3401.     bhi    mask_ex            * yes, return
  3402.     btst    d3,d2            * bit is clear ?
  3403.     beq    mask0            * try next
  3404.     tst.b    d1            * now bit is set. first time ?
  3405.     beq    mask00            * yes, no need '/'
  3406.     move.b    #'/',(a3)+        * separator
  3407. mask00    bsr    mask_Rn            * print start sequence register
  3408.     bsr    mask1            * what's fellow ?
  3409.     bra    mask0
  3410.  
  3411. mask1    st    d1            * not first time
  3412.     addq.b    #1,d3            * next bit
  3413.     cmpi.b    #15,d3            * last bit ?
  3414.     bhi    mask_ex            * yes, return
  3415.     btst    d3,d2            * bit is clear ?
  3416.     beq    mask_ex            * yes, only one in sequense, return
  3417.     move.b    #'-',(a3)+        * else, '-' separator.
  3418.  
  3419. mask_2    btst    d3,d2            * 1 again ?
  3420.     beq    maskend            * no, exit loop
  3421.     cmpi.b    #15,d3            * last bit ?
  3422.     beq    mask_Rn            * yes, print register and return
  3423.     addq.b    #1,d3            * yes, try next bit
  3424.     bra    mask_2
  3425.  
  3426. maskend    subq.b    #1,d3            * no of last bit set
  3427.     bra    mask_Rn            * print end of sequence register 
  3428.  
  3429. mask_ex    rts
  3430.  
  3431. *------------------------------------------------------------------------------*
  3432.  
  3433. mask_Rn:                * print one of d0-d7,a0-a7 (d0=0-15)
  3434.  
  3435.     move.b    d3,d7
  3436.     andi.b    #7,d7            * register no
  3437.     cmpi.b    #8,d3            * adr or data register
  3438.     bcs    data_reg
  3439.     bcc    adr_reg
  3440.  
  3441. *------------------------------------------------------------------------------*
  3442.  
  3443. _ext    lea    k_ext,a0
  3444.     bsr    copy_s            * copy keyword
  3445.     bsr    do_size
  3446.     move.b    1(a5),d7        * register no.
  3447.     bsr    data_reg        * data register
  3448.     bra    term
  3449.  
  3450. *------------------------------------------------------------------------------*
  3451.  
  3452. _nbcd:                    * mnemo. for nbcd
  3453.  
  3454.     move.b    #'N',(a3)+
  3455.     lea    k_bcd,a0
  3456.     bsr    copy_s            * copy keyword
  3457.     bra    tab_ea            * ea
  3458.  
  3459. *------------------------------------------------------------------------------*
  3460.  
  3461. mv_CCR:                    * move ea,CCR
  3462.  
  3463.     bsr    do_mv
  3464.     moveq    #1,d4            * word size
  3465.     bsr    ea_0_5            * ea
  3466.     move.b    #comma,(a3)+
  3467.     bsr    do_CCR            * (in xxxi)
  3468.     bra    term
  3469.  
  3470. do_mv    lea    k_move,a0
  3471.     bsr    copy_s            * copy keyword
  3472.     move.b    #tab,(a3)+
  3473.     rts
  3474.  
  3475. *------------------------------------------------------------------------------*
  3476.  
  3477. mv_USP:                    * move USP,An  or move An,USP
  3478.  
  3479.     bsr    do_mv            * (in mv_CCR)
  3480.     move.b    1(a5),d7        * register no.
  3481.     btst    #3,d7            * bit 3 of opcode
  3482.     beq    An_USP            * 0: -> An,USP
  3483.     bsr    do_USP            * 1: -> USP,An
  3484.     move.b    #comma,(a3)+
  3485.     bsr    adr_reg            * address register
  3486.     bra    term
  3487. An_USP    bsr    adr_reg            * address register
  3488.     move.b    #comma,(a3)+
  3489.     bsr    do_USP
  3490.     bra    term
  3491.  
  3492. do_USP    lea    k_usp,a0
  3493.     bsr    copy_s
  3494.     rts
  3495.  
  3496.  
  3497. *------------------------------------------------------------------------------*
  3498.  
  3499. mv_f_SR:                * move SR,ea
  3500.  
  3501.     bsr    do_mv            * (in mv_CCR)
  3502.     bsr    do_SR
  3503.     move.b    #comma,(a3)+
  3504.     bsr    ea_0_5            * ea
  3505.     bra    term
  3506.  
  3507. *------------------------------------------------------------------------------*
  3508.  
  3509. mv_t_SR:                * move ea,SR
  3510.  
  3511.     bsr    do_mv            * (in mv_CCR)
  3512.     moveq    #1,d4            * word size
  3513.     bsr    ea_0_5            * ea
  3514.     move.b    #comma,(a3)+
  3515.     bsr    do_SR
  3516.     bra    term
  3517.  
  3518. *------------------------------------------------------------------------------*
  3519.  
  3520. _chk_lea:                    * mnemo. for chk or lea
  3521.  
  3522.     btst    #6,1(a5)        * 1 -> lea   0 -> chk
  3523.     beq    _chk
  3524.     lea    k_lea,a0
  3525.     moveq    #2,d3            * type: ea,An
  3526.     bra    do_chk
  3527. _chk    lea    k_chk,a0
  3528.     moveq    #0,d3            * type: ea,Dn
  3529. do_chk    bsr    copy_s            * copy keyword
  3530.     move.b    #tab,(a3)+
  3531.     bsr    ea_Rn            * (in op_mode)
  3532.     bra    term
  3533.  
  3534. *------------------------------------------------------------------------------*
  3535.  
  3536. _clr:                    * mnemo. for clr
  3537.  
  3538.     lea    k_clr,a0
  3539.     bra    sz_ea
  3540.  
  3541. *------------------------------------------------------------------------------*
  3542.  
  3543. _neg:                    * mnemo. for neg
  3544.  
  3545.     lea    k_neg,a0
  3546.     bra    sz_ea
  3547.  
  3548. *------------------------------------------------------------------------------*
  3549.  
  3550. _negx:                    * mnemo. for negx
  3551.  
  3552.     lea    k_negx,a0
  3553.     bra    sz_ea
  3554.  
  3555. *------------------------------------------------------------------------------*
  3556.  
  3557. _not:                    * mnemo. for not
  3558.  
  3559.     lea    k_not,a0
  3560.     bra    sz_ea
  3561.  
  3562. *------------------------------------------------------------------------------*
  3563.  
  3564. _tst:                    * mnemo. for tst
  3565.  
  3566.     lea    k_tst,a0
  3567.     bra    sz_ea
  3568.  
  3569. *------------------------------------------------------------------------------*
  3570. *----------------------------- data and space ---------------------------------*
  3571. *------------------------------------------------------------------------------*
  3572.  
  3573.     .data
  3574.  
  3575. mode_tb    .dc.l    data_reg        * mode = %000
  3576.     .dc.l    adr_reg            * mode = %001
  3577.     .dc.l    indirect        * mode = %010
  3578.     .dc.l    post_inc        * mode = %011
  3579.     .dc.l    pre_dec            * mode = %100
  3580.     .dc.l    indir_disp        * mode = %101
  3581.     .dc.l    index_disp        * mode = %110
  3582.     .dc.l    mode7            * mode = %111
  3583.  
  3584. md7_tb    .dc.l    abs_w            * reg = %000
  3585.     .dc.l    abs_l            * reg = %001
  3586.     .dc.l    pc_disp            * reg = %010
  3587.     .dc.l    pc_index        * reg = %011
  3588.     .dc.l    immediat        * reg = %100
  3589.     .dc.l    unknown            * reg = %101
  3590.     .dc.l    unknown            * reg = %110
  3591.     .dc.l    unknown            * reg = %111
  3592.  
  3593.  
  3594. k_add    .dc.b    "ADD",0            * mnemotechnic keyword
  3595. k_and    .dc.b    "AND",0
  3596. k_bcd    .dc.b    "BCD",0
  3597. k_chg    .dc.b    "CHG",0
  3598. k_chk    .dc.b    "CHK",0
  3599. k_clr    .dc.b    "CLR",0
  3600. k_cmp    .dc.b    "CMP",0
  3601. k_div    .dc.b    "DIV",0
  3602. k_eor    .dc.b    "EOR",0
  3603. k_exg    .dc.b    "EXG",0
  3604. k_ext    .dc.b    "EXT",0
  3605. k_illg    .dc.b    "ILLEGAL",0
  3606. k_jmp    .dc.b    "JMP",0
  3607. k_jsr    .dc.b    "JSR",0
  3608. k_lea    .dc.b    "LEA",0
  3609. k_link    .dc.b    "LINK",0
  3610. k_move    .dc.b    "MOVE",0
  3611. k_mul    .dc.b    "MUL",0
  3612. k_neg    .dc.b    "NEG",0
  3613. k_negx    .dc.b    "NEGX",0
  3614. k_nop    .dc.b    "NOP",0
  3615. k_not    .dc.b    "NOT",0
  3616. k_or    .dc.b    "OR",0
  3617. k_pea    .dc.b    "PEA",0
  3618. k_reset    .dc.b    "RESET",0
  3619. k_rte    .dc.b    "RTE",0
  3620. k_rtr    .dc.b    "RTR",0
  3621. k_rts    .dc.b    "RTS",0
  3622. k_stop    .dc.b    "STOP",0
  3623. k_set    .dc.b    "SET",0
  3624. k_sub    .dc.b    "SUB",0
  3625. k_swap    .dc.b    "SWAP",0
  3626. k_tas    .dc.b    "TAS",0
  3627. k_trap    .dc.b    "TRAP",0
  3628. k_trapv    .dc.b    "TRAPV",0
  3629. k_tst    .dc.b    "TST",0
  3630. k_unlk    .dc.b    "UNLK",0
  3631.  
  3632. k_ccr    .dc.b    "CCR",0
  3633. k_sr    .dc.b    "SR",0
  3634. k_usp    .dc.b    "USP",0
  3635.  
  3636. cc_code    .dc.b    "T F HILSCCCSNEEQVCVSPLMIGELTGTLE"
  3637.  
  3638. over_s    .dc.b    13,10,"Walkback over stack",0
  3639. intro_s    .dc.b    13,10,27,'v',27,'p'," ***** MONITOR, by Alain Birtz ****** "
  3640.     .dc.b    27,'q',0
  3641. main_s    .dc.b    13,10,"Disasm Trace Hexed Search Free"
  3642.     .dc.b    " Move Load Break Go Regs CCR Info Exit: ",0
  3643. bye_s    .dc.b    13,10,"Byebye",0
  3644. adr_1st    .dc.b    13,27,'K',"start address: ",0
  3645. src_s    .dc.b    13,27,'K',"SOURCE",10,0
  3646. dest_s    .dc.b    13,27,'K',"DESTINATION",10,0
  3647. adr_end    .dc.b    27,'C',27,'C',27,'C',27,'C',27,'C',27,'C',"     end address: ",0
  3648. free_s    .dc.b    13,27,'K',"bytes free:            need: ",0
  3649. in_s    .dc.b    13,27,'K',"input-> Memory, Prg file, Data file, Exit: ",0
  3650. out_s    .dc.b    13,27,'K',"output-> Screen, Printer, File, Exit: ",0
  3651. s_move    .dc.b    13,27,'K',"1- file to memory  2- memory to file "
  3652.     .dc.b    " 3- memory to memory  0- exit: ",0
  3653. name_s    .dc.b    13,27,'K',"pathname: ",0
  3654. io_er_s    .dc.b    13,10,"I/O error no  $____",0
  3655. altd_s    .dc.b    13,27,'K',"Do you want save altered file (N,Y): ",0
  3656. c_p_a_s    .dc.b    "  Current prg. adr: ________",0
  3657. from_s    .dc.b    13,10,27,'p'," From $________ to $________ ",27,'q',10,0
  3658. b_pg_s    .dc.b    13,10,27,'p'," text $________-$________   data $________"
  3659.     .dc.b    "-$________   bss $________-$________ ",27,'q',10,0
  3660. s_CCR    .dc.b    13,10," ________   status: _____    ",0
  3661. codeCCR    .dc.b    "XNZVC"
  3662. newCCRs    .dc.b    13,27,'K',"New CCR value [$0-$1f]: ",0
  3663. data_s    .dc.b    13,27,'K',"DATA file: ",0
  3664. prg_s    .dc.b    13,"PRG file: ",0
  3665. break_s    .dc.b    13,27,'K',"break point address: ",0
  3666. brkno_s    .dc.b    13,27,'K',"how many time: ",0
  3667. srch_s    .dc.b    13,27,'K',"search Ascii string, Byte "
  3668.     .dc.b    "hexa string , Exit: ",0
  3669. ascii_s    .dc.b    13,27,'K',"ascii string: ",0
  3670. byte_s    .dc.b    13,27,'K',"hexa byte string: ",0
  3671. found_s    .dc.b    13,10,"found at memory adr. $",0
  3672. fileoff    .dc.b    13,10,"found at file offset $",0
  3673. notfind    .dc.b    13,10,"not found",0
  3674. s_at    .dc.b    " at: ",0
  3675. pause_s    .dc.b    13,10,"pause",0
  3676. cont_s    .dc.b    13,27,'K',"continue",0
  3677. work_s    .dc.b    13,10,"working...",0
  3678. trcnt_s    .dc.b    13,27,'K',"traced ________ instruction",0
  3679.  
  3680. excep_s    .dc.b    13,10,">>>>> traced exception <<<<< ",0
  3681. s_bus    .dc.b    "Bus error",0
  3682. s_adr    .dc.b    "Address error",0
  3683. s_illeg    .dc.b    "Illegal intruction",0
  3684. c_s    .dc.b    27,'j',0            * save cursor pos
  3685. c_r    .dc.b    27,'k',0            * restore cursor pos
  3686. r_on_s    .dc.b    27,'p',0            * reverse on string
  3687. r_off_s    .dc.b    27,'q',0            * reverse off string
  3688. n_line    .dc.b    13,10,0
  3689. up_ln    .dc.b    27,'I',13,0            * cursor up + CR (with scrool)
  3690. up_s    .dc.b    27,'A',0            * cursor up
  3691. down_s    .dc.b    27,'B',0            * cursor down
  3692. left_s    .dc.b    27,'D',0            * cursor left
  3693. right_s    .dc.b    27,'C',0            * cursor up
  3694. R_s    .dc.b    27,'j',27,'A',13,27,'C',27,'C',0
  3695. R_ex_s    .dc.b    27,'k',27,'q',0            * in sel_R routine
  3696. R_chr_s    .dc.b    '0',27,'D',0
  3697.  
  3698. cur_fg    .dc.w    -1                * cursor position flag
  3699.  
  3700.     .even
  3701.  
  3702. exepnew    .dc.l    v_bus, v_adr, v_illeg
  3703. base_pg    .dc.l    0                * base page address
  3704.  
  3705. *------------------------------------------------------------------------------*
  3706.  
  3707.     .bss
  3708.  
  3709.     .even
  3710.  
  3711. ipname    .ds.b    74                * pathname + command tail (prg)
  3712. tail    .ds.b    72                * command tail only
  3713. idname    .ds.b    74                * input pathname (data)
  3714. odname    .ds.b    74                * output pathname (data)
  3715. temp_s    .ds.b    8                * temporary storage
  3716. str    .ds.b    240                * work space
  3717. mv_str    .ds.b    159                * move space
  3718. outdev    .ds.b    1                * output device id
  3719. indev    .ds.b    1                * input device id
  3720. op_main    .ds.b    1                * main option
  3721. altd_fg .ds.b    1                * altered flag
  3722. wr_fg    .ds.b    0                * write mem flag
  3723. srch_fg    .ds.b    1                * found something: 1, else: 0
  3724. wildstr    .ds.b    20                * wildcard string
  3725. srchstr    .ds.b    23                * search string
  3726. nil_val    .ds.b    1                * no value read flag
  3727. wait_fg    .ds.b    1                * pause flag
  3728. sp_up    .ds.b    1                * stack up flag
  3729. sp_dn    .ds.b    1                * stack down flag
  3730. sp_eq    .ds.b    1                * stack equal flag
  3731.  
  3732.     .even
  3733.  
  3734. srchreg    .ds.l    6                * register save for search
  3735. svtrap8    .ds.l    1                * save trap 8 vector
  3736. brkcode    .ds.w    1                * code replaced by trap #8
  3737. brkadr    .ds.l    1                * break point address
  3738. brkno    .ds.l    1                * no of the breakpoint
  3739. exepold    .ds.l    3                * save old exception vector
  3740. saveCCR    .ds.w    1                * CCR saved...
  3741. ihandle    .ds.w    1                * input file handle
  3742. ohandle    .ds.w    1                * output file handle
  3743. dta    .ds.l    1                * disk transfert address
  3744. sv_ssp    .ds.l    1                * supervisor save area
  3745. save1st    .ds.l    1                * start address
  3746. saveend    .ds.l    1                * end address
  3747. regs    .ds.l    16                * register save
  3748. cur_adr    .ds.l    1                * current address
  3749. sp_1st    .ds.l    1                * stack pointer reference
  3750. trcount    .ds.l    1                * instruction counter
  3751. mon_sp    .ds.l    1                * monitor stack pointer
  3752. prg_sp    .ds.l    1                * program stack pointer
  3753.  
  3754.     .ds.l    400
  3755. prg_stk    .ds.l    1                * program stack
  3756.     .ds.l    100
  3757. mon_stk    .ds.l    1                * monitor stack
  3758.  
  3759.     .end
  3760. əəəəəəəəəəəəəə